Skip to content

Commit 63a8b97

Browse files
committed
refactor: add tag on pull request
1 parent c22c03e commit 63a8b97

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

.github/workflows/new_tag.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Tag on version bump
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
tag:
13+
name: Create tag if version changed
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Get current version from pyproject.toml
23+
id: current
24+
run: |
25+
VERSION=$(grep '^version =' pyproject.toml | cut -d '"' -f2)
26+
echo "version=$VERSION" >> $GITHUB_OUTPUT
27+
28+
- name: Get previous version from main~1
29+
id: previous
30+
run: |
31+
git checkout HEAD~1
32+
PREV_VERSION=$(grep '^version =' pyproject.toml | cut -d '"' -f2)
33+
echo "version=$PREV_VERSION" >> $GITHUB_OUTPUT
34+
35+
- name: Compare versions and create tag if changed
36+
if: steps.current.outputs.version != steps.previous.outputs.version
37+
run: |
38+
git config user.name "github-actions[bot]"
39+
40+
TAG="v${{ steps.current.outputs.version }}"
41+
git tag "$TAG"
42+
git push origin "$TAG"

0 commit comments

Comments
 (0)