name: Release
on:
push:
branches: [main]
workflow_dispatch:
inputs:
tag:
description: "Tag to (re)publish, e.g. v0.2.3 — manual dispatch only"
required: true
type: string
jobs:
release-please:
if: github.event_name == 'push'
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
outputs:
release_created: ${{ steps.release.outputs.release_created }}
tag_name: ${{ steps.release.outputs.tag_name }}
steps:
- uses: googleapis/release-please-action@v4
id: release
with:
config-file: release-please-config.json
manifest-file: .release-please-manifest.json
publish:
needs: release-please
if: |
always() &&
(
(needs.release-please.result == 'success' && needs.release-please.outputs.release_created == 'true')
|| github.event_name == 'workflow_dispatch'
)
runs-on: macos-latest
permissions:
contents: write id-token: write env:
TAG: ${{ github.event.inputs.tag || needs.release-please.outputs.tag_name }}
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.event.inputs.tag || needs.release-please.outputs.tag_name }}
- uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-apple-darwin,x86_64-apple-darwin
- name: Build universal macOS binary + notify helper
run: |
cargo build --release --target aarch64-apple-darwin
cargo build --release --target x86_64-apple-darwin
# Assemble artifacts under target/ (already gitignored) so the working
# tree stays clean for the `cargo publish` step below — no
# --allow-dirty, and no genuine source change gets masked.
mkdir -p target/dist
lipo -create -output target/dist/triage \
target/aarch64-apple-darwin/release/triage \
target/x86_64-apple-darwin/release/triage
bash scripts/triage-notify/build.sh target/dist
tar -czf "target/triage-macos-universal.tar.gz" -C target/dist triage triage-notify.app
- name: Attach binary to the GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: gh release upload "$TAG" target/triage-macos-universal.tar.gz --clobber
- name: Authenticate to crates.io (Trusted Publishing)
id: crates-auth
uses: rust-lang/crates-io-auth-action@v1
- name: Publish to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ steps.crates-auth.outputs.token }}
run: cargo publish
- name: Bump Homebrew formula
if: env.HOMEBREW_TAP_TOKEN != ''
run: |
set -euo pipefail
VERSION="${TAG#v}"
CRATE_URL="https://static.crates.io/crates/triage-tui/triage-tui-${VERSION}.crate"
# Wait for the crates.io CDN to serve the freshly published .crate.
for i in $(seq 1 12); do
if curl -fsSL "$CRATE_URL" -o crate.tgz; then break; fi
echo "waiting for $CRATE_URL ($i)…"; sleep 15
done
SHA=$(shasum -a 256 crate.tgz | awk '{print $1}')
git clone "https://x-access-token:${HOMEBREW_TAP_TOKEN}@github.com/inkless/homebrew-triage.git" tap
cd tap
# macos runner → BSD sed (-i '').
sed -i '' -E "s|triage-tui-[0-9]+\.[0-9]+\.[0-9]+\.crate|triage-tui-${VERSION}.crate|" Formula/triage.rb
sed -i '' -E "s|^ version \".*\"| version \"${VERSION}\"|" Formula/triage.rb
sed -i '' -E "s|^ sha256 \".*\"| sha256 \"${SHA}\"|" Formula/triage.rb
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git commit -am "triage ${VERSION}"
git push