Skip to content

Commit 1ecd19f

Browse files
committed
An attempt to add CI
1 parent 48413f3 commit 1ecd19f

6 files changed

Lines changed: 295 additions & 8 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Install libav (Linux)
2+
description: >-
3+
Installs FFmpeg 7 libav development packages on Ubuntu (24.04 runners) via
4+
ppa:ubuntuhandbook1/ffmpeg7.
5+
6+
runs:
7+
using: composite
8+
steps:
9+
- shell: bash
10+
run: |
11+
set -euxo pipefail
12+
sudo apt-get update
13+
sudo apt-get install -y --no-install-recommends \
14+
ca-certificates \
15+
software-properties-common
16+
sudo add-apt-repository -y ppa:ubuntuhandbook1/ffmpeg7
17+
sudo apt-get update
18+
sudo apt-get install -y --no-install-recommends \
19+
pkg-config \
20+
libavcodec-dev \
21+
libavdevice-dev \
22+
libavfilter-dev \
23+
libavformat-dev \
24+
libavutil-dev
Lines changed: 256 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,256 @@
1+
name: rolling-release
2+
3+
on:
4+
push:
5+
branches: ["main", "master"]
6+
workflow_dispatch:
7+
8+
concurrency:
9+
group: rolling-release
10+
cancel-in-progress: true
11+
12+
permissions:
13+
contents: write
14+
15+
env:
16+
BIN: stream-failover-relay
17+
ROLLING_TAG: rolling
18+
19+
jobs:
20+
build:
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
include:
25+
- id: linux_amd64
26+
runs_on: ubuntu-24.04
27+
platform: linux
28+
arch: amd64
29+
archive_ext: tar.gz
30+
public_only: false
31+
32+
- id: linux_arm64
33+
runs_on: ubuntu-24.04-arm
34+
platform: linux
35+
arch: arm64
36+
archive_ext: tar.gz
37+
public_only: true
38+
39+
- id: macos_amd64
40+
runs_on: macos-14
41+
platform: darwin
42+
arch: amd64
43+
archive_ext: tar.gz
44+
public_only: false
45+
46+
- id: macos_arm64
47+
runs_on: macos-14
48+
platform: darwin
49+
arch: arm64
50+
archive_ext: tar.gz
51+
public_only: false
52+
53+
- id: windows_amd64
54+
runs_on: windows-latest
55+
platform: windows
56+
arch: amd64
57+
archive_ext: zip
58+
public_only: false
59+
60+
runs-on: ${{ matrix.runs_on }}
61+
62+
steps:
63+
- name: Avoid CRLF issues in MSYS2
64+
if: ${{ !(github.event.repository.private && matrix.public_only) && runner.os == 'Windows' }}
65+
run: git config --global core.autocrlf input
66+
67+
- name: Checkout
68+
if: ${{ !(github.event.repository.private && matrix.public_only) }}
69+
uses: actions/checkout@v4
70+
71+
- name: Set up Go
72+
if: ${{ !(github.event.repository.private && matrix.public_only) }}
73+
uses: actions/setup-go@v5
74+
with:
75+
go-version-file: go.mod
76+
cache: true
77+
78+
# ---- deps: Linux ----
79+
- name: Install deps (Linux)
80+
if: ${{ !(github.event.repository.private && matrix.public_only) && runner.os == 'Linux' }}
81+
uses: ./.github/actions/install-libav-linux
82+
83+
# ---- deps: macOS ----
84+
- name: Install deps (macOS)
85+
if: ${{ !(github.event.repository.private && matrix.public_only) && runner.os == 'macOS' }}
86+
run: |
87+
set -euxo pipefail
88+
brew update
89+
brew install pkg-config
90+
if brew info ffmpeg@7 >/dev/null 2>&1; then
91+
brew install ffmpeg@7 || brew upgrade ffmpeg@7
92+
brew link --overwrite --force ffmpeg@7
93+
else
94+
brew install ffmpeg || brew upgrade ffmpeg
95+
fi
96+
export PKG_CONFIG_PATH="/opt/homebrew/opt/ffmpeg@7/lib/pkgconfig:/usr/local/opt/ffmpeg@7/lib/pkgconfig:/opt/homebrew/lib/pkgconfig:/usr/local/lib/pkgconfig:${PKG_CONFIG_PATH:-}"
97+
98+
# ---- deps: Windows (MSYS2 UCRT64) ----
99+
- name: Setup MSYS2 (Windows)
100+
if: ${{ !(github.event.repository.private && matrix.public_only) && runner.os == 'Windows' }}
101+
uses: msys2/setup-msys2@v2
102+
with:
103+
msystem: UCRT64
104+
update: true
105+
path-type: inherit
106+
install: >-
107+
git
108+
zip
109+
mingw-w64-ucrt-x86_64-gcc
110+
mingw-w64-ucrt-x86_64-pkg-config
111+
112+
# ---- build/package: Linux + macOS ----
113+
- name: Build & package (Linux/macOS)
114+
if: ${{ !(github.event.repository.private && matrix.public_only) && runner.os != 'Windows' }}
115+
run: |
116+
set -euxo pipefail
117+
118+
SHA_SHORT="${GITHUB_SHA::7}"
119+
VERSION="rolling-${SHA_SHORT}"
120+
OUT="dist"
121+
STAGE="${OUT}/stage_${{ matrix.id }}"
122+
ARCHIVE="${OUT}/${BIN}_${VERSION}_${{ matrix.platform }}_${{ matrix.arch }}.${{ matrix.archive_ext }}"
123+
124+
rm -rf "${STAGE}"
125+
mkdir -p "${STAGE}" "${OUT}"
126+
127+
CGO_ENABLED=1 go build -trimpath -o "${STAGE}/${BIN}" "."
128+
129+
tar -czf "${ARCHIVE}" -C "${STAGE}" .
130+
131+
# ---- build/package: Windows ----
132+
- name: Build & package (Windows)
133+
if: ${{ !(github.event.repository.private && matrix.public_only) && runner.os == 'Windows' }}
134+
shell: msys2 {0}
135+
run: |
136+
set -euxo pipefail
137+
138+
# Ensure MSYS2 packages (including FFmpeg headers) are fully up-to-date.
139+
pacman -Syu --noconfirm
140+
141+
# Install FFmpeg development package from MSYS2.
142+
pacman -S --noconfirm --needed mingw-w64-ucrt-x86_64-ffmpeg
143+
pacman -S --noconfirm --needed mingw-w64-ucrt-x86_64-pkg-config
144+
145+
SHA_SHORT="${GITHUB_SHA::7}"
146+
VERSION="rolling-${SHA_SHORT}"
147+
OUT="dist"
148+
STAGE="${OUT}/stage_${{ matrix.id }}"
149+
ARCHIVE="${OUT}/${BIN}_${VERSION}_${{ matrix.platform }}_${{ matrix.arch }}.${{ matrix.archive_ext }}"
150+
151+
rm -rf "${STAGE}"
152+
mkdir -p "${STAGE}" "${OUT}"
153+
154+
command -v go
155+
go version
156+
157+
CGO_ENABLED=1 go build -trimpath -o "${STAGE}/${BIN}.exe" "."
158+
159+
echo "FFmpeg-related DLLs in /ucrt64/bin (diagnostic):"
160+
ls -la /ucrt64/bin/avcodec-*.dll /ucrt64/bin/avformat-*.dll /ucrt64/bin/avutil-*.dll 2>/dev/null || true
161+
162+
# Bundle common runtime DLLs (best-effort for MSYS2/UCRT64)
163+
ffmpeg_prefix="$(pkg-config --variable=prefix libavcodec)"
164+
ffmpeg_bindir="${ffmpeg_prefix}/bin"
165+
cp -f "${ffmpeg_bindir}"/avcodec-*.dll "${STAGE}/" || true
166+
cp -f "${ffmpeg_bindir}"/avformat-*.dll "${STAGE}/" || true
167+
cp -f "${ffmpeg_bindir}"/avutil-*.dll "${STAGE}/" || true
168+
cp -f "${ffmpeg_bindir}"/avdevice-*.dll "${STAGE}/" || true
169+
cp -f "${ffmpeg_bindir}"/avfilter-*.dll "${STAGE}/" || true
170+
cp -f "${ffmpeg_bindir}"/swresample-*.dll "${STAGE}/" || true
171+
cp -f "${ffmpeg_bindir}"/swscale-*.dll "${STAGE}/" || true
172+
cp -f "${ffmpeg_bindir}"/postproc-*.dll "${STAGE}/" || true
173+
cp -f /ucrt64/bin/libwinpthread-1.dll "${STAGE}/" || true
174+
cp -f /ucrt64/bin/libgcc_s_seh-1.dll "${STAGE}/" || true
175+
cp -f /ucrt64/bin/libstdc++-6.dll "${STAGE}/" || true
176+
177+
(cd "${STAGE}" && zip -9 -r "../$(basename "${ARCHIVE}")" .)
178+
179+
- name: Debug dist output
180+
if: ${{ !(github.event.repository.private && matrix.public_only) }}
181+
run: |
182+
set -euxo pipefail
183+
echo "PWD: $(pwd)"
184+
ls -la
185+
echo "dist tree:"
186+
find dist -maxdepth 2 -type f -print || true
187+
188+
- name: Upload build artifacts
189+
if: ${{ !(github.event.repository.private && matrix.public_only) }}
190+
uses: actions/upload-artifact@v4
191+
with:
192+
name: ${{ matrix.id }}
193+
path: |
194+
dist/*.tar.gz
195+
dist/*.zip
196+
if-no-files-found: error
197+
198+
release:
199+
runs-on: ubuntu-24.04
200+
needs: [build]
201+
if: ${{ always() }}
202+
203+
steps:
204+
- name: Checkout (for tagging)
205+
uses: actions/checkout@v4
206+
with:
207+
fetch-depth: 0
208+
fetch-tags: true
209+
210+
- name: Download all artifacts
211+
uses: actions/download-artifact@v4
212+
with:
213+
path: dist
214+
215+
- name: Gather archives + SHA256SUMS
216+
run: |
217+
set -euxo pipefail
218+
219+
mkdir -p dist/out
220+
find dist -type f \( -name '*.tar.gz' -o -name '*.zip' \) -print -exec cp -f {} dist/out/ \;
221+
222+
cd dist/out
223+
shopt -s nullglob
224+
files=( *.tar.gz *.zip )
225+
if [ ${#files[@]} -eq 0 ]; then
226+
echo "No archives found under dist/out" >&2
227+
exit 1
228+
fi
229+
sha256sum "${files[@]}" > SHA256SUMS
230+
231+
- name: Move rolling tag to this commit
232+
run: |
233+
set -euxo pipefail
234+
git config user.name "github-actions[bot]"
235+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
236+
git tag -f "${ROLLING_TAG}" "${GITHUB_SHA}"
237+
git push origin -f "${ROLLING_TAG}"
238+
239+
- name: Publish/Update rolling GitHub Release
240+
uses: ncipollo/release-action@v1
241+
with:
242+
tag: ${{ env.ROLLING_TAG }}
243+
name: rolling
244+
prerelease: true
245+
allowUpdates: true
246+
updateOnlyUnreleased: true
247+
removeArtifacts: true
248+
replacesArtifacts: true
249+
artifacts: "dist/out/*.tar.gz,dist/out/*.zip,dist/out/SHA256SUMS"
250+
token: ${{ secrets.GITHUB_TOKEN }}
251+
body: |
252+
Automated rolling build.
253+
254+
Commit: ${{ github.sha }}
255+
Branch: ${{ github.ref_name }}
256+
Workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
.vscode
1+
/.vscode
2+
/stream-failover-relay
3+
/.github/copilot-instructions.md

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ stream-failover-relay \
3232

3333
Here `rtmp://my.server/live/main` will be the primary source, `/opt/brb.mp4` the BRB placeholder, and `rtmp://remote.server/live/out` the output destination.
3434

35-
## Build
35+
## Install
36+
37+
Go to [Releases](https://github.com/xaionaro-go/stream-failover-relay/releases) and download
38+
the executable you need.
39+
40+
## Build from the source
3641

3742
```bash
3843
apt install -y libavcodec-dev libavdevice-dev libavfilter-dev libavformat-dev libavutil-dev

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ go 1.24.4
44

55
toolchain go1.24.11
66

7-
replace github.com/asticode/go-astiav v0.36.0 => github.com/xaionaro-go/astiav v0.0.0-20251210224931-afff9c0f1cf7
7+
replace github.com/asticode/go-astiav v0.36.0 => github.com/xaionaro-go/astiav v0.0.0-20251213191451-08d78322abe4
88

99
require (
1010
github.com/asticode/go-astiav v0.36.0
1111
github.com/facebookincubator/go-belt v0.0.0-20250308011339-62fb7027b11f
1212
github.com/spf13/pflag v1.0.6
13-
github.com/xaionaro-go/avpipeline v0.0.0-20251213160139-acdfe272aae6
13+
github.com/xaionaro-go/avpipeline v0.0.0-20251213175624-8b9f33e7605b
1414
github.com/xaionaro-go/observability v0.0.0-20250622130956-24b7017284e4
1515
github.com/xaionaro-go/secret v0.0.0-20250111141743-ced12e1082c2
1616
)

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,16 @@ github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
8585
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
8686
github.com/xaionaro-go/androidetc v0.0.0-20250824193302-b7ecebb3b825 h1:4f2P9/JASUXx2GWhQ6wyGlwOtr+nIfM6PUq9wTHqHmM=
8787
github.com/xaionaro-go/androidetc v0.0.0-20250824193302-b7ecebb3b825/go.mod h1:IvRt8Hto32EGtBEf7A94HVxiYEt7hGXLWabjdnUYmAE=
88-
github.com/xaionaro-go/astiav v0.0.0-20251210224931-afff9c0f1cf7 h1:82uBxJBN54u1WIESVEq2dihwZzM2anKvigElxXLNANA=
89-
github.com/xaionaro-go/astiav v0.0.0-20251210224931-afff9c0f1cf7/go.mod h1:txVrlvD3ErCtyacQ6WBMarn9+oD1V8vk33dWmVCGQhM=
88+
github.com/xaionaro-go/astiav v0.0.0-20251213191451-08d78322abe4 h1:s9nQJd9HwGXvXoEd7aKUnbWWNUB0mGNv5jeCKIawAhU=
89+
github.com/xaionaro-go/astiav v0.0.0-20251213191451-08d78322abe4/go.mod h1:txVrlvD3ErCtyacQ6WBMarn9+oD1V8vk33dWmVCGQhM=
9090
github.com/xaionaro-go/audio v0.0.0-20250426140416-6a9b3f1c8737 h1:82T1ghLMySGzft1c11Go+GtSQI67Ixk6Mq+nZ52CnnI=
9191
github.com/xaionaro-go/audio v0.0.0-20250426140416-6a9b3f1c8737/go.mod h1:m1JTs/Kqw+iPlQ081sfXA2JPBIylezwe5c3w//oV3Gs=
9292
github.com/xaionaro-go/avcommon v0.0.0-20250823173020-6a2bb1e1f59d h1:++uR850Cqo5qXGTfAq60p2sIfq7oSYK0x0KoKL8B9Ts=
9393
github.com/xaionaro-go/avcommon v0.0.0-20250823173020-6a2bb1e1f59d/go.mod h1:kjLo1LasgdDJqbTGD5bbEM+D6RiZSbf5ZT8yiPFF1BA=
9494
github.com/xaionaro-go/avmediacodec v0.0.0-20250505012527-c819676502d8 h1:FZn9+TN3uHhohfpanWkR9lFNHApizznZbML6XjvEgTU=
9595
github.com/xaionaro-go/avmediacodec v0.0.0-20250505012527-c819676502d8/go.mod h1:2W2Kp/HJFXcFBppQ4YytgDy/ydFL3hGc23xSB1U/Luc=
96-
github.com/xaionaro-go/avpipeline v0.0.0-20251213160139-acdfe272aae6 h1:8yi58/+6uJyLW64BpgB3HB0O9t0WJc90dpxcBQjN2j0=
97-
github.com/xaionaro-go/avpipeline v0.0.0-20251213160139-acdfe272aae6/go.mod h1:NfyT1vfrFPqeOGKcYDteSRCwj+b24ggk254rHFfY274=
96+
github.com/xaionaro-go/avpipeline v0.0.0-20251213175624-8b9f33e7605b h1:+8UWvp9tdN/9z/vDCigKwOnp4edWHa0n0ILOKuV7K/Y=
97+
github.com/xaionaro-go/avpipeline v0.0.0-20251213175624-8b9f33e7605b/go.mod h1:NfyT1vfrFPqeOGKcYDteSRCwj+b24ggk254rHFfY274=
9898
github.com/xaionaro-go/gorex v0.0.0-20241010205749-bcd59d639c4d h1:9DyH0lboWWzKUwiqGmp9sTZ3bSPhgJHiiWgV+hqY9Uo=
9999
github.com/xaionaro-go/gorex v0.0.0-20241010205749-bcd59d639c4d/go.mod h1:yI0EvHC6Ir5WIZp3tEk7o42/QqeTb9pkII+T8p4FlPo=
100100
github.com/xaionaro-go/libsrt v0.0.0-20250505013920-61d894a3b7e9 h1:z5K1pa9cJZ2oqFNWyyxrxO/50Hv4Gn+1kkfXTHkoKNM=

0 commit comments

Comments
 (0)