name: Release
on:
push:
tags:
- "v*"
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
archive: tar.gz
- os: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
archive: tar.gz
- os: macos-15 target: aarch64-apple-darwin
archive: tar.gz
- os: macos-15-intel target: x86_64-apple-darwin
archive: tar.gz
- os: windows-latest
target: x86_64-pc-windows-msvc
archive: zip
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set version from tag
shell: bash
run: |
VERSION="${GITHUB_REF_NAME#v}"
echo "Setting version to ${VERSION}"
bash scripts/set-version.sh "${VERSION}"
- name: Install ALSA headers (Linux)
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y libasound2-dev
- name: Install Rust target
run: rustup target add ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Build binary
run: cargo build --release --target ${{ matrix.target }}
- name: Package (Unix)
if: matrix.archive == 'tar.gz'
run: |
mkdir -p dist
cp target/${{ matrix.target }}/release/audiorouter dist/
tar czf audiorouter-${{ matrix.target }}.tar.gz -C dist audiorouter
- name: Package (Windows)
if: matrix.archive == 'zip'
shell: bash
run: |
mkdir -p dist
cp target/${{ matrix.target }}/release/audiorouter.exe dist/
cd dist && 7z a ../audiorouter-${{ matrix.target }}.zip audiorouter.exe
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: audiorouter-${{ matrix.target }}
path: audiorouter-${{ matrix.target }}.${{ matrix.archive }}
retention-days: 7
publish-crates:
name: Publish to crates.io
runs-on: ubuntu-latest
needs: build
permissions:
id-token: write steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set version from tag
run: |
VERSION="${GITHUB_REF_NAME#v}"
echo "Setting version to ${VERSION}"
bash scripts/set-version.sh "${VERSION}"
- name: Install ALSA headers
run: sudo apt-get update && sudo apt-get install -y libasound2-dev
- name: Authenticate to crates.io
id: auth
uses: rust-lang/crates-io-auth-action@v1
- name: Publish
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
run: |
VERSION="${GITHUB_REF_NAME#v}"
PUBLISHED="$(curl -fsS -A "audiorouter release workflow" \
"https://crates.io/api/v1/crates/audiorouter/${VERSION}" \
&& echo yes || echo no)"
if [ "${PUBLISHED}" = "yes" ]; then
echo "✓ audiorouter ${VERSION} is already published; skipping"
else
cargo publish --no-verify --allow-dirty
fi
github-release:
name: GitHub Release
runs-on: ubuntu-latest
needs: build
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: ${{ github.ref_name }}
generate_release_notes: true
files: artifacts/*