Skip to content

Commit 78d4a67

Browse files
Merge branch 'feat/release-workflow' into staging
2 parents b711c51 + 06712db commit 78d4a67

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Release
2+
3+
# When the root package.json version is bumped and merged to main, tag the
4+
# commit vX.Y.Z and publish a GitHub Release with auto-generated notes.
5+
# Bumping the version is a deliberate PR change; publishing is automatic.
6+
on:
7+
push:
8+
branches: ["main"]
9+
paths:
10+
- 'package.json'
11+
- '.github/workflows/release.yml'
12+
13+
permissions:
14+
contents: write
15+
16+
concurrency:
17+
group: release
18+
cancel-in-progress: false
19+
20+
jobs:
21+
release:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 0
28+
29+
- name: Read version from package.json
30+
id: version
31+
run: echo "version=$(node -p "require('./package.json').version")" >> "$GITHUB_OUTPUT"
32+
33+
- name: Check whether this release already exists
34+
id: check
35+
env:
36+
GH_TOKEN: ${{ github.token }}
37+
run: |
38+
if gh release view "v${{ steps.version.outputs.version }}" >/dev/null 2>&1; then
39+
echo "exists=true" >> "$GITHUB_OUTPUT"
40+
echo "v${{ steps.version.outputs.version }} already released — nothing to do."
41+
else
42+
echo "exists=false" >> "$GITHUB_OUTPUT"
43+
fi
44+
45+
- name: Create tag and GitHub Release
46+
if: steps.check.outputs.exists == 'false'
47+
env:
48+
GH_TOKEN: ${{ github.token }}
49+
run: |
50+
gh release create "v${{ steps.version.outputs.version }}" \
51+
--target "${{ github.sha }}" \
52+
--title "v${{ steps.version.outputs.version }}" \
53+
--generate-notes

0 commit comments

Comments
 (0)