Skip to content

Commit 2570010

Browse files
committed
feat: workflow to create release
1 parent c97dd57 commit 2570010

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

.github/workflows/release.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Release on Package Update
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- main
8+
paths:
9+
- 'package.json'
10+
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
20+
- name: Extract version from package.json
21+
id: version
22+
run: |
23+
VERSION=$(jq -r '.version' package.json)
24+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
25+
echo "Extracted version: $VERSION"
26+
27+
- name: Check if release already exists
28+
id: check_release
29+
run: |
30+
VERSION=${{ steps.version.outputs.VERSION }}
31+
if gh release view "v$VERSION" > /dev/null 2>&1; then
32+
echo "EXISTS=true" >> $GITHUB_OUTPUT
33+
else
34+
echo "EXISTS=false" >> $GITHUB_OUTPUT
35+
fi
36+
env:
37+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
39+
- name: Create Release
40+
if: steps.check_release.outputs.EXISTS == 'false'
41+
run: |
42+
VERSION=${{ steps.version.outputs.VERSION }}
43+
gh release create "v$VERSION" \
44+
--title "v$VERSION" \
45+
--notes "Release v$VERSION" \
46+
--latest
47+
env:
48+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)