name: Release
on:
push:
tags: ['v*']
permissions:
contents: write
jobs:
test:
if: "!contains(github.ref_name, 'beta')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
with:
shared-key: ci-test
save-if: false
- run: cargo fmt --check
- run: cargo clippy -- -D warnings
- run: cargo test
build:
needs: test
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
cross: false
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
cross: true
- target: x86_64-apple-darwin
os: macos-15-large
cross: false
- target: aarch64-apple-darwin
os: macos-latest
cross: false
- target: x86_64-pc-windows-msvc
os: windows-latest
cross: false
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Install cross
if: matrix.cross
run: cargo install cross --locked
- name: Build with cross
if: matrix.cross
run: cross build --release --target ${{ matrix.target }}
- name: Build
if: "!matrix.cross"
run: cargo build --release --target ${{ matrix.target }}
- name: Rename binary (unix)
if: runner.os != 'Windows'
run: mv target/${{ matrix.target }}/release/roam roam-${{ matrix.target }}
- name: Rename binary (windows)
if: runner.os == 'Windows'
run: mv target/${{ matrix.target }}/release/roam.exe roam-${{ matrix.target }}.exe
- name: Upload artifact (unix)
if: runner.os != 'Windows'
uses: actions/upload-artifact@v4
with:
name: roam-${{ matrix.target }}
path: roam-${{ matrix.target }}
- name: Upload artifact (windows)
if: runner.os == 'Windows'
uses: actions/upload-artifact@v4
with:
name: roam-${{ matrix.target }}
path: roam-${{ matrix.target }}.exe
publish:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: artifacts/
- name: Create release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG="${GITHUB_REF#refs/tags/}"
# Collect all binaries
FILES=()
for dir in artifacts/roam-*/; do
for file in "$dir"*; do
[ -f "$file" ] && FILES+=("$file")
done
done
gh release create "$TAG" \
--title "Release $TAG" \
--generate-notes \
"${FILES[@]}"