Skip to content

Commit 1a5a703

Browse files
committed
ci: release action
1 parent bbeb77f commit 1a5a703

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

.github/workflows/release.yaml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Release new version
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release-type:
7+
type: choice
8+
description: Select the release type
9+
required: true
10+
options:
11+
- major
12+
- patch
13+
- minor
14+
15+
permissions:
16+
id-token: write
17+
contents: write
18+
19+
jobs:
20+
release:
21+
runs-on: ubuntu-latest
22+
name: Release new version
23+
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v5
27+
with:
28+
fetch-depth: 0 # Required to get all existing tags
29+
fetch-tags: true
30+
31+
- name: Stop if there are no new changes
32+
run: |
33+
LATEST_TAG=$(git describe --tags --abbrev=0 --always)
34+
LAST_COMMIT=$(git rev-parse HEAD)
35+
LASTEST_TAG_COMMIT=$(git rev-list -n 1 $LATEST_TAG)
36+
if [ "$LASTEST_TAG_COMMIT" == "$LAST_COMMIT" ]; then
37+
echo "No new changes since the last tag. Stopping the workflow."
38+
exit 1
39+
fi
40+
exit 0
41+
42+
- name: Setup NodeJS
43+
uses: actions/setup-node@v5
44+
with:
45+
node-version-file: '.node-version'
46+
registry-url: 'https://registry.npmjs.org'
47+
48+
- name: Install dependencies
49+
run: npm ci
50+
51+
- name: Create new version
52+
run: |
53+
git config --global user.name 'github-actions[bot]'
54+
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
55+
npm version ${{ github.event.inputs.release-type }} -m "chore: v%s"
56+
57+
- name: Build project
58+
run: |
59+
npm run build
60+
61+
- name: Publish new version
62+
run: |
63+
git push --follow-tags
64+
npm publish

0 commit comments

Comments
 (0)