11name : Release
22
33on :
4- push :
5- tags :
6- - ' v*.*.*' # Trigger on version tags like v1.0.0, v0.1.0, etc.
7- workflow_dispatch : # Allow manual triggers
4+ workflow_dispatch :
5+ inputs :
6+ bump :
7+ description : ' Version bump type'
8+ required : true
9+ type : choice
10+ options :
11+ - patch
12+ - minor
13+ - major
14+ default : patch
15+
16+ concurrency :
17+ group : release
18+ cancel-in-progress : false # Never cancel an in-progress release
819
920permissions :
10- contents : write # Required for creating releases
21+ contents : write # Required for creating releases, pushing version commits and tags
1122 packages : write # Required for pushing to GHCR
1223 id-token : write # Required for cosign keyless signing
1324
1425jobs :
15- setup :
16- name : Extract Version
26+ bump-version :
27+ name : Bump Version
1728 runs-on : ubuntu-latest
1829 outputs :
19- version : ${{ steps.version .outputs.version }}
20- version_number : ${{ steps.version .outputs.version_number }}
30+ version : ${{ steps.bump .outputs.version }}
31+ version_number : ${{ steps.bump .outputs.version_number }}
2132 steps :
2233 - name : Checkout code
2334 uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4
35+ with :
36+ fetch-depth : 0
37+ fetch-tags : true
38+
39+ - name : Verify branch
40+ if : github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/heads/v')
41+ run : |
42+ echo "::error::Release should be triggered on main or a maintenance branch (v*.x), got: ${{ github.ref }}"
43+ exit 1
2444
2545 - name : Setup Node.js
26- if : github.event_name == 'workflow_dispatch'
2746 uses : actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
2847 with :
2948 node-version : ' 22'
3049
31- - name : Extract version from tag
32- id : version
50+ - name : Bump version
51+ id : bump
3352 run : |
34- if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
35- VERSION=$(node -p "require('./package.json').version")
36- echo "version=v$VERSION" >> $GITHUB_OUTPUT
37- echo "version_number=$VERSION" >> $GITHUB_OUTPUT
38- else
39- VERSION="${GITHUB_REF#refs/tags/}"
40- VERSION_NUMBER="${VERSION#v}"
41- echo "version=$VERSION" >> $GITHUB_OUTPUT
42- echo "version_number=$VERSION_NUMBER" >> $GITHUB_OUTPUT
43- fi
53+ git config user.name "github-actions[bot]"
54+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
55+
56+ # npm version creates a commit and tag (e.g., "v0.21.0")
57+ npm version ${{ inputs.bump }} --no-git-tag-version
58+ VERSION=$(node -p "require('./package.json').version")
59+
60+ git add package.json package-lock.json
61+ git commit -m "$VERSION"
62+ git tag "v$VERSION"
63+ git push origin HEAD --tags
64+
65+ echo "version=v$VERSION" >> $GITHUB_OUTPUT
66+ echo "version_number=$VERSION" >> $GITHUB_OUTPUT
67+ echo "Bumped to v$VERSION (${{ inputs.bump }})"
4468
4569 build-squid :
4670 name : Build Squid Image
4771 runs-on : ubuntu-latest
48- needs : setup
72+ needs : bump-version
4973 steps :
5074 - name : Checkout code
5175 uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4
76+ with :
77+ ref : ${{ needs.bump-version.outputs.version }}
5278
5379 - name : Log in to GitHub Container Registry
5480 uses : docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3
76102 push : true
77103 platforms : linux/amd64,linux/arm64
78104 tags : |
79- ghcr.io/${{ github.repository }}/squid:${{ needs.setup .outputs.version_number }}
105+ ghcr.io/${{ github.repository }}/squid:${{ needs.bump-version .outputs.version_number }}
80106 ghcr.io/${{ github.repository }}/squid:latest
81107 cache-from : type=gha,scope=squid
82108 cache-to : type=gha,mode=max,scope=squid
@@ -103,10 +129,12 @@ jobs:
103129 build-agent :
104130 name : Build Agent Image
105131 runs-on : ubuntu-latest
106- needs : setup
132+ needs : bump-version
107133 steps :
108134 - name : Checkout code
109135 uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4
136+ with :
137+ ref : ${{ needs.bump-version.outputs.version }}
110138
111139 - name : Log in to GitHub Container Registry
112140 uses : docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3
@@ -134,7 +162,7 @@ jobs:
134162 push : true
135163 platforms : linux/amd64,linux/arm64
136164 tags : |
137- ghcr.io/${{ github.repository }}/agent:${{ needs.setup .outputs.version_number }}
165+ ghcr.io/${{ github.repository }}/agent:${{ needs.bump-version .outputs.version_number }}
138166 ghcr.io/${{ github.repository }}/agent:latest
139167 # Disable cache for agent image to ensure security-critical packages
140168 # (like libcap2-bin for capability dropping) are always freshly installed
@@ -162,10 +190,12 @@ jobs:
162190 build-api-proxy :
163191 name : Build API Proxy Image
164192 runs-on : ubuntu-latest
165- needs : setup
193+ needs : bump-version
166194 steps :
167195 - name : Checkout code
168196 uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4
197+ with :
198+ ref : ${{ needs.bump-version.outputs.version }}
169199
170200 - name : Log in to GitHub Container Registry
171201 uses : docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3
@@ -193,7 +223,7 @@ jobs:
193223 push : true
194224 platforms : linux/amd64,linux/arm64
195225 tags : |
196- ghcr.io/${{ github.repository }}/api-proxy:${{ needs.setup .outputs.version_number }}
226+ ghcr.io/${{ github.repository }}/api-proxy:${{ needs.bump-version .outputs.version_number }}
197227 ghcr.io/${{ github.repository }}/api-proxy:latest
198228 cache-from : type=gha,scope=api-proxy
199229 cache-to : type=gha,mode=max,scope=api-proxy
@@ -222,10 +252,12 @@ jobs:
222252 build-agent-act :
223253 name : Build Agent-Act Image
224254 runs-on : ubuntu-latest
225- needs : setup
255+ needs : bump-version
226256 steps :
227257 - name : Checkout code
228258 uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4
259+ with :
260+ ref : ${{ needs.bump-version.outputs.version }}
229261
230262 - name : Log in to GitHub Container Registry
231263 uses : docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3
@@ -248,7 +280,7 @@ jobs:
248280 push : true
249281 platforms : linux/amd64
250282 tags : |
251- ghcr.io/${{ github.repository }}/agent-act:${{ needs.setup .outputs.version_number }}
283+ ghcr.io/${{ github.repository }}/agent-act:${{ needs.bump-version .outputs.version_number }}
252284 ghcr.io/${{ github.repository }}/agent-act:latest
253285 build-args : |
254286 BASE_IMAGE=ghcr.io/catthehacker/ubuntu:act-24.04
@@ -276,10 +308,14 @@ jobs:
276308 release :
277309 name : Create Release
278310 runs-on : ubuntu-latest
279- needs : [setup , build-squid, build-agent, build-api-proxy, build-agent-act]
311+ needs : [bump-version , build-squid, build-agent, build-api-proxy, build-agent-act]
280312 steps :
281313 - name : Checkout code
282314 uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4
315+ with :
316+ ref : ${{ needs.bump-version.outputs.version }} # Checkout the version tag
317+ fetch-depth : 0 # Full history for tag listing and changelog generation
318+ fetch-tags : true
283319
284320 - name : Setup Node.js
285321 uses : actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
@@ -322,7 +358,7 @@ jobs:
322358 run : |
323359 npx tsx scripts/ci/smoke-test-binary.ts \
324360 release/awf-linux-x64 \
325- ${{ needs.setup .outputs.version_number }}
361+ ${{ needs.bump-version .outputs.version_number }}
326362
327363 - name : Verify arm64 binary is valid ELF
328364 run : |
@@ -344,7 +380,7 @@ jobs:
344380 id : previous_tag
345381 run : |
346382 set -euo pipefail
347- CURRENT_TAG="${{ needs.setup .outputs.version }}"
383+ CURRENT_TAG="${{ needs.bump-version .outputs.version }}"
348384
349385 # Use git tags directly (more reliable than gh release list)
350386 # Get the most recent tag that is not the current tag
@@ -357,7 +393,7 @@ jobs:
357393 id : changelog
358394 run : |
359395 set -euo pipefail
360- CURRENT_TAG="${{ needs.setup .outputs.version }}"
396+ CURRENT_TAG="${{ needs.bump-version .outputs.version }}"
361397 PREVIOUS_TAG="${{ steps.previous_tag.outputs.previous_tag }}"
362398
363399 echo "Generating changelog from $PREVIOUS_TAG to $CURRENT_TAG"
@@ -419,8 +455,8 @@ jobs:
419455 - name : Create Release Notes
420456 id : release_notes
421457 env :
422- VERSION : ${{ needs.setup .outputs.version }}
423- VERSION_NUMBER : ${{ needs.setup .outputs.version_number }}
458+ VERSION : ${{ needs.bump-version .outputs.version }}
459+ VERSION_NUMBER : ${{ needs.bump-version .outputs.version_number }}
424460 REPOSITORY : ${{ github.repository }}
425461 run : |
426462 set -euo pipefail
@@ -447,11 +483,11 @@ jobs:
447483 - name : Create GitHub Release
448484 uses : softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2.5.0
449485 with :
450- tag_name : ${{ needs.setup .outputs.version }}
451- name : Release ${{ needs.setup .outputs.version }}
486+ tag_name : ${{ needs.bump-version .outputs.version }}
487+ name : Release ${{ needs.bump-version .outputs.version }}
452488 body_path : release_notes.md
453489 draft : false
454- prerelease : ${{ contains(needs.setup .outputs.version, 'alpha') || contains(needs.setup .outputs.version, 'beta') || contains(needs.setup .outputs.version, 'rc') }}
490+ prerelease : ${{ contains(needs.bump-version .outputs.version, 'alpha') || contains(needs.bump-version .outputs.version, 'beta') || contains(needs.bump-version .outputs.version, 'rc') }}
455491 files : |
456492 release/awf-linux-x64
457493 release/awf-linux-arm64
0 commit comments