Skip to content

Commit ea66973

Browse files
authored
ci: add workflow to auto tag and bump package.json (#9)
1 parent 3eba852 commit ea66973

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

.github/workflows/publish-tag.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Cut a new tag (also auto updates package.json and package-lock.json)
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release_type:
7+
description: 'Version bump type (patch, minor, major)'
8+
required: true
9+
default: 'patch'
10+
11+
jobs:
12+
bump-version:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v3
18+
19+
- name: Set up Node.js
20+
uses: actions/setup-node@v3
21+
with:
22+
node-version: '20'
23+
24+
- name: Get triggering user's email
25+
run: |
26+
user_email=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/users/${{ github.actor }} | jq -r '.email')
27+
if [ -z "$user_email" ] || [ "$user_email" == "null" ]; then
28+
user_email="github-actions@github.com"
29+
fi
30+
echo "user_email=$user_email" >> $GITHUB_ENV
31+
32+
- name: Configure Git with the triggering user's info
33+
run: |
34+
git config user.name "${{ github.actor }}"
35+
git config user.email "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com"
36+
37+
38+
- name: Bump version and push tag
39+
run: |
40+
npm install
41+
npm version ${{ github.event.inputs.release_type }} -m "chore: bump version to %s"
42+
git push --follow-tags
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)