1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
name: Auto-tag on version bump
# When the version in Cargo.toml changes on main, push a matching
# vX.Y.Z tag. That tag triggers release.yml, which builds prebuilts,
# publishes the GitHub Release, and pushes to crates.io + npm.
#
# Net effect: bumping Cargo.toml version + push is the only manual
# step required to ship a new release across all channels.
on:
push:
branches:
paths:
permissions:
contents: write
actions: write # needed for `gh workflow run` (dispatches release.yml)
jobs:
tag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0 # need full history to enumerate tags
- name: Determine version
id: ver
run: |
version=$(awk -F'"' '/^version[[:space:]]*=/{print $2; exit}' Cargo.toml)
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "tag=v$version" >> "$GITHUB_OUTPUT"
- name: Skip if tag already exists
id: gate
run: |
if git rev-parse "refs/tags/${{ steps.ver.outputs.tag }}" >/dev/null 2>&1; then
echo "tag ${{ steps.ver.outputs.tag }} already exists — nothing to do"
echo "skip=true" >> "$GITHUB_OUTPUT"
else
echo "skip=false" >> "$GITHUB_OUTPUT"
fi
- name: Tag and push
if: steps.gate.outputs.skip == 'false'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name "mbrassey"
git config user.email "matt@brassey.io"
git tag -a "${{ steps.ver.outputs.tag }}" -m "agtop ${{ steps.ver.outputs.version }}"
git push origin "${{ steps.ver.outputs.tag }}"
# Tags pushed by GITHUB_TOKEN don't fan out to other workflows
# (GitHub guards against infinite loops). Explicitly dispatch
# the release workflow against the freshly-pushed ref so the
# build / publish-crates / publish-npm jobs actually run.
- name: Dispatch release workflow
if: steps.gate.outputs.skip == 'false'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh workflow run release.yml --ref "${{ steps.ver.outputs.tag }}"