Skip to content

Commit f425da3

Browse files
committed
ci: Add workflow for automated tagging
1 parent 43e6923 commit f425da3

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

.github/workflows/tagging.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Tagging 🏷️
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches: [main]
7+
workflow_dispatch:
8+
inputs:
9+
version:
10+
description: "Version to release (e.g., 1.2.3)"
11+
required: true
12+
type: string
13+
14+
jobs:
15+
create-tag:
16+
if: |
17+
github.event_name == 'workflow_dispatch' ||
18+
(github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/'))
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: write
22+
steps:
23+
- uses: actions/checkout@v6
24+
25+
- name: Determine version
26+
id: version
27+
run: |
28+
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
29+
VERSION="${{ inputs.version }}"
30+
else
31+
VERSION=$(echo "${{ github.event.pull_request.head.ref }}" | sed 's|^release/||')
32+
fi
33+
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
34+
echo "Invalid version format: $VERSION"
35+
exit 1
36+
fi
37+
echo "version=$VERSION" >> $GITHUB_OUTPUT
38+
39+
- uses: fregante/setup-git-user@v2
40+
41+
- name: Bump version and push tag
42+
run: |
43+
npm version ${{ steps.version.outputs.version }}
44+
git push origin ${{ github.ref_name }} --tags

0 commit comments

Comments
 (0)