Skip to content

Commit 58891a4

Browse files
authored
ci: update version with tag name
1 parent 178580a commit 58891a4

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

.github/workflows/release.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
tags:
66
- 'v*'
77
workflow_dispatch:
8+
inputs:
9+
version:
10+
description: 'Version to release'
11+
required: true
812

913
jobs:
1014
release:
@@ -23,6 +27,20 @@ jobs:
2327
- name: Install dependencies
2428
run: npm install
2529

30+
- name: Extract version from tag or dispatch
31+
id: get_version
32+
run: |
33+
if [ "${{ github.event_name }}" == "push" ]; then
34+
echo "Version from tag ${GITHUB_REF##*/}"
35+
echo "::set-output name=version::${GITHUB_REF##*/v}"
36+
elif [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
37+
echo "Version from dispatch input ${{ github.event.inputs.version }}"
38+
echo "::set-output name=version::${{ github.event.inputs.version }}"
39+
fi
40+
41+
- name: Update version in package.json
42+
run: npm version ${{ steps.get_version.outputs.version }} --no-git-tag-version
43+
2644
- name: Build
2745
run: npm run build
2846

@@ -37,4 +55,4 @@ jobs:
3755
- name: Publish
3856
env:
3957
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
40-
run: npm publish -r --access public --no-git-checks
58+
run: npm publish --access public --no-git-checks

0 commit comments

Comments
 (0)