|
| 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 }} |
0 commit comments