Skip to content

Commit 78df39f

Browse files
normprovostclaude
andauthored
Add release workflow for tagging (#406)
* Add release workflow for tagging Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Scope app token to contents:write only Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 5dfc0ea commit 78df39f

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: "Version to release (semver, no leading v — e.g. 5.0.3)"
8+
required: true
9+
type: string
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
tag:
16+
runs-on: ubuntu-latest
17+
environment: master
18+
steps:
19+
- name: Validate version
20+
env:
21+
VERSION: ${{ inputs.version }}
22+
run: |
23+
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then
24+
echo "Version must be semver (e.g. 5.0.3 or 5.0.3-beta.1)"
25+
exit 1
26+
fi
27+
28+
- name: Mint App installation token
29+
id: app-token
30+
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
31+
with:
32+
app-id: ${{ secrets.PACKAGIST_PUBLISHER_APP_ID }}
33+
private-key: ${{ secrets.PACKAGIST_PUBLISHER_PRIVATE_KEY }}
34+
permission-contents: write
35+
36+
- name: Create annotated tag on master HEAD
37+
env:
38+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
39+
VERSION: ${{ inputs.version }}
40+
REPO: ${{ github.repository }}
41+
run: |
42+
set -euo pipefail
43+
SHA=$(gh api "repos/$REPO/commits/master" --jq .sha)
44+
echo "Tagging $SHA as $VERSION"
45+
46+
TAG_OBJ=$(gh api -X POST "repos/$REPO/git/tags" \
47+
-f tag="$VERSION" \
48+
-f message="Release $VERSION" \
49+
-f object="$SHA" \
50+
-f type=commit \
51+
--jq .sha)
52+
53+
gh api -X POST "repos/$REPO/git/refs" \
54+
-f ref="refs/tags/$VERSION" \
55+
-f sha="$TAG_OBJ"

0 commit comments

Comments
 (0)