Skip to content

Release

Release #10

Workflow file for this run

---
name: Release
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*'
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
concurrency:
group: release
cancel-in-progress: true
jobs:
build:
name: Build
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, ubuntu-24.04-arm]
runs-on: ${{ matrix.os }}
permissions:
contents: read
steps:
- name: Check out
uses: actions/checkout@v6
- name: Check formatting
run: cargo fmt --all -- --check
- name: Build
run: cargo build --verbose
- name: Test
run: cargo test --verbose
release:
name: Release
runs-on: ubuntu-latest
needs: build
permissions:
contents: write
steps:
- name: Check out
uses: actions/checkout@v6
- name: Verify tag matches Cargo.toml version
shell: bash
id: get_version
run: |
tag="${GITHUB_REF_NAME}"
version="${tag#v}"
echo "Tag: $tag, Version: $version"
pkg_version=$(awk -F '"' '/^\[package\]/{p=1} p && $1 ~ /^version = / {print $2; exit}' Cargo.toml)
if [[ -z "$pkg_version" ]]; then
echo "Could not read [package].version from Cargo.toml"
exit 1
fi
if [[ "$pkg_version" != "$version" ]]; then
echo "Version mismatch: Cargo.toml has $pkg_version but tag is $tag"
exit 1
fi
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Install cargo-deb and cargo-generate-rpm
run: |
cargo install cargo-deb --locked
cargo install cargo-generate-rpm --locked
- name: Build Debian package
run: cargo deb
- name: Build RPM package
run: cargo generate-rpm
- name: Publish to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish --locked
- name: Create GitHub Release and upload assets
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: |
target/debian/*.deb
target/generate-rpm/*.rpm
name: ${{ steps.get_version.outputs.version }}
tag_name: ${{ github.ref_name }}
generate_release_notes: true
prerelease: ${{ contains(github.ref_name, '-') }}
make_latest: true