name: Release
on:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+
env:
CARGO_TERM_COLOR: always
jobs:
check-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Install toml-cli
run: cargo install toml-cli
- name: Check version
run: test "v$(toml get -r Cargo.toml package.version)" = "${{ github.ref_name }}"
- name: Verify Cargo.lock matches Cargo.toml
run: cargo metadata --locked --format-version=1 > /dev/null
build-linux:
runs-on: ubuntu-latest
needs: check-version
strategy:
matrix:
target: [
x86_64-unknown-linux-musl,
aarch64-unknown-linux-musl,
armv7-unknown-linux-musleabihf
]
steps:
- uses: actions/checkout@v7
- name: Install cross
run: cargo install cross
- name: Build with cross
run: cross build --locked --release --target ${{ matrix.target }}
- name: Rename binary
run: |
mkdir -p dist
cp target/${{ matrix.target }}/release/leadr dist/leadr-${{ github.ref_name }}-${{ matrix.target }}
- uses: actions/upload-artifact@v7
with:
name: leadr-${{ github.ref_name }}-${{ matrix.target }}
path: dist/leadr-${{ github.ref_name }}-${{ matrix.target }}
build-macos:
runs-on: macos-latest
needs: check-version
strategy:
matrix:
target: [x86_64-apple-darwin, aarch64-apple-darwin]
steps:
- uses: actions/checkout@v7
- name: Install Rust target
run: rustup target add ${{ matrix.target }}
- name: Build (macOS)
run: cargo build --locked --release --target ${{ matrix.target }}
- name: Rename binary
run: |
mkdir -p dist
cp target/${{ matrix.target }}/release/leadr dist/leadr-${{ github.ref_name }}-${{ matrix.target }}
- uses: actions/upload-artifact@v7
with:
name: leadr-${{ github.ref_name }}-${{ matrix.target }}
path: dist/leadr-${{ github.ref_name }}-${{ matrix.target }}
release-to-github:
needs: [build-linux, build-macos]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
fetch-tags: true
- uses: actions/download-artifact@v8
with:
merge-multiple: true
path: dist
- name: Generate release notes
id: release_notes
run: |
set -e
echo -e "This release contains the following changes:\n\n---\n" > release_notes.md
PREV_TAG=$(git describe --tags --abbrev=0 "${GITHUB_REF_NAME}^" 2>/dev/null || echo "")
if [ -z "$PREV_TAG" ]; then
echo "No previous tag found, including all merge commits."
git log --merges --pretty=format:'### %s%n%n%b%n%n---' >> release_notes.md
else
echo "Previous tag: $PREV_TAG"
git log "$PREV_TAG"..HEAD --merges --pretty=format:'### %s%n%n%b%n%n---' >> release_notes.md
fi
echo "Generated release notes:"
cat release_notes.md
- uses: ncipollo/release-action@v1
with:
artifacts: "dist/*"
bodyFile: release_notes.md
publish-to-crates-io:
needs: [build-linux, build-macos]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Publish to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish --locked --no-verify
update-homebrew-tap:
runs-on: ubuntu-latest
needs: release-to-github
steps:
- name: Update homebrew tap
run: gh workflow run update-formula.yml -f version=${{ github.ref_name }} -R ll-nick/homebrew-leadr
env:
GITHUB_TOKEN: ${{ secrets.HOMEBREW_LEADR_GH_TOKEN }}