Skip to content

Commit 4bfca29

Browse files
authored
Merge pull request #23 from increments/fix-add-git-tags-in-github-actions
GithubActionsからバージョンタグを自動で追加するように修正
2 parents 8f34a8b + bf579f8 commit 4bfca29

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

.github/workflows/publish-package.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_dispatch:
55

66
permissions:
7-
contents: read
7+
contents: write
88
packages: write
99

1010
concurrency:
@@ -21,10 +21,23 @@ jobs:
2121
with:
2222
node-version: "18.16.0"
2323
registry-url: "https://registry.npmjs.org"
24+
- name: Set version number to environment variable
25+
run: |
26+
node -p -e '`RELEASED_PACKAGE_VERSION=v${require("./package.json").version}`' >> $GITHUB_ENV
27+
node -p -e '`RELEASED_MAJOR_VERSION=v${require("./package.json").version}`' | awk -F. '{print $1}' >> $GITHUB_ENV
2428
- run: yarn install
2529
- run: yarn run build
2630
env:
2731
NODE_ENV: "production"
28-
- run: yarn publish --access public
32+
- name: Publish package
33+
run: yarn publish --access public
2934
env:
3035
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
36+
- name: Create version tag
37+
run: |
38+
git config --global user.name 'github-actions[bot]'
39+
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
40+
git tag -a ${{ env.RELEASED_PACKAGE_VERSION }} -m 'Release ${{ env.RELEASED_PACKAGE_VERSION }}'
41+
git tag -f ${{ env.RELEASED_MAJOR_VERSION }} ${{ env.RELEASED_PACKAGE_VERSION }}
42+
git push origin ${{ env.RELEASED_PACKAGE_VERSION }}
43+
git push -f origin ${{ env.RELEASED_MAJOR_VERSION }}

0 commit comments

Comments
 (0)