From e7a4d3caf88989c423f3e55cf0693a14ea4b82d6 Mon Sep 17 00:00:00 2001 From: David Perl Date: Mon, 27 Jul 2026 11:03:54 +0200 Subject: [PATCH] feat: semantic release workflow --- .gitea/workflows/release.yaml | 41 +++++++++++++++++++++++++++++++++-- README.md | 21 ++++++++++++++++++ 2 files changed, 60 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml index eaa6395..40c4798 100644 --- a/.gitea/workflows/release.yaml +++ b/.gitea/workflows/release.yaml @@ -2,8 +2,8 @@ name: Release on: push: - tags: - - "v*" + branches: + - main env: RUST_BACKTRACE: 1 @@ -13,9 +13,44 @@ concurrency: cancel-in-progress: true jobs: + release: + name: Semantic release + runs-on: ubuntu-latest + outputs: + # "true" only when semantic-release actually published a release. + released: ${{ steps.semantic_release.outputs.released }} + steps: + # Check out with the bot token so semantic-release can push the version + # bump and tag past branch protection (the default token cannot). + - uses: actions/checkout@v6 + with: + fetch-depth: 0 + token: ${{ secrets.MX_GITEA_BOT_TOKEN }} + - uses: https://github.com/dtolnay/rust-toolchain@stable + - uses: https://github.com/Swatinem/rust-cache@v2 + - name: Install cargo-edit + uses: https://github.com/taiki-e/install-action@v2 + with: + tool: cargo-edit + - name: Semantic release + id: semantic_release + env: + # Used by the curl step in .releaserc.json to create the Gitea release. + GITEA_URL: https://gitea.psi.ch + GITEA_REPO: ${{ github.repository }} + MX_GITEA_BOT_TOKEN: ${{ secrets.MX_GITEA_BOT_TOKEN }} + run: | + npx --yes \ + -p semantic-release@25 \ + -p @semantic-release/exec \ + -p @semantic-release/git \ + semantic-release + build-rpm: name: Build and push RPM runs-on: ubuntu-latest + needs: release + if: needs.release.outputs.released == 'true' steps: - uses: actions/checkout@v6 - uses: https://github.com/dtolnay/rust-toolchain@stable @@ -23,6 +58,8 @@ jobs: - name: Build RPM run: | + # Pick up the version bump semantic-release just committed. + git pull cargo build --release strip -s target/release/aarel cargo install cargo-generate-rpm diff --git a/README.md b/README.md index 17340de..4f719e3 100644 --- a/README.md +++ b/README.md @@ -24,3 +24,24 @@ selects a different config file; it defaults to `data/defaults.json`. `gui` and `server` pick their config entry from the detected beamline. Use `--entry ` to launch a different one. + +## Development + +``` +cargo build # build +cargo test # run the tests +cargo fmt --all # format +cargo clippy --all-targets --all-features -- -D warnings # lint +``` + +Releases are automated with [semantic-release]: merging a PR to `main` derives +the next version from the commit history, bumps `Cargo.toml`, tags the release +and builds the RPM. + +> **Commit messages must follow [Conventional Commits].** The release version and +> notes are generated from them, so a commit that isn't `feat:`, `fix:`, etc. +> produces no release. Use `feat:` for a minor bump, `fix:` for a patch, and a +> `feat!:`/`fix!:` (or a `BREAKING CHANGE:` footer) for a major bump. + +[semantic-release]: https://semantic-release.gitbook.io/ +[Conventional Commits]: https://www.conventionalcommits.org/