Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 71 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
name: Release

# Push a tag such as v0.6.1 or v0.6.1-rc.1 on a commit of main to publish a
# release. A tag with a hyphen (for example -rc.1) becomes a pre-release.
on:
release:
types: [created]
push:
tags: ["v*"]

permissions:
contents: write
Expand All @@ -11,7 +13,71 @@ env:
CARGO_TERM_COLOR: always

jobs:
verify:
runs-on: ubuntu-latest
outputs:
prerelease: ${{ steps.kind.outputs.prerelease }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Check that the tag is on main
run: |
git fetch origin main
if ! git merge-base --is-ancestor "$GITHUB_SHA" origin/main; then
echo "::error::Tag $GITHUB_REF_NAME is not on main"
exit 1
fi

- name: Check the tag against Cargo.toml
id: kind
run: |
tag="${GITHUB_REF_NAME#v}"
version="$(sed -n 's/^version = "\(.*\)"$/\1/p' Cargo.toml | head -n 1)"
if [[ "$tag" == *-* ]]; then
echo "prerelease=true" >> "$GITHUB_OUTPUT"
else
if [[ "$tag" != "$version" ]]; then
echo "::error::Tag $GITHUB_REF_NAME does not match version $version in Cargo.toml"
exit 1
fi
echo "prerelease=false" >> "$GITHUB_OUTPUT"
fi

- name: Install Linux dependencies
run: |
sudo apt-get update
sudo apt-get install -y libasound2-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libxkbcommon-dev

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable

- name: Run tests
run: cargo test

create-release:
needs: verify
runs-on: ubuntu-latest
steps:
- name: Create the release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PRERELEASE: ${{ needs.verify.outputs.prerelease }}
run: |
if gh release view "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" > /dev/null 2>&1; then
echo "Release $GITHUB_REF_NAME exists already"
exit 0
fi
flags=()
if [[ "$PRERELEASE" == "true" ]]; then
flags+=(--prerelease)
fi
gh release create "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" \
--verify-tag --title "$GITHUB_REF_NAME" --generate-notes "${flags[@]}"

build:
needs: create-release
strategy:
matrix:
include:
Expand Down Expand Up @@ -53,8 +119,7 @@ jobs:
cp "target/${{ matrix.target }}/release/${{ matrix.artifact_name }}" "${{ matrix.asset_name }}"

- name: Upload release asset
uses: softprops/action-gh-release@v2
with:
files: ${{ matrix.asset_name }}
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload "$GITHUB_REF_NAME" "${{ matrix.asset_name }}" --repo "$GITHUB_REPOSITORY" --clobber
12 changes: 12 additions & 0 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,15 @@ Some tests and helpers are built only on Unix or Linux, so also run `cargo clipp
## Where files live at run time

BabbleBoop keeps `config.toml`, `total_cost.txt`, and the `recordings` folder in one data folder chosen at startup; see [Where BabbleBoop keeps its files](README.md#where-babbleboop-keeps-its-files) in the README for the lookup order.

## Releasing

Push a tag that starts with `v` on a commit of `main`. The Release workflow then checks that the tag is on `main`, runs the tests, creates the GitHub release with generated notes, and attaches the Windows, Linux and macOS builds.

- A tag with a hyphen, such as `v0.6.1-rc.1`, becomes a pre-release, so it does not replace the latest release.
- For a tag without a hyphen, such as `v0.6.1`, the version in `Cargo.toml` must match, or the workflow stops before it creates the release.

```
git tag v0.6.1-rc.2 origin/main
git push origin v0.6.1-rc.2
```
Loading