-
Notifications
You must be signed in to change notification settings - Fork 1
49 lines (41 loc) · 1.17 KB
/
create-tag.yml
File metadata and controls
49 lines (41 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
name: Create Version Tag from pyproject.toml
on:
push:
branches:
- main
paths:
- "pyproject.toml"
workflow_dispatch: # Enables manual runs
permissions:
contents: write
jobs:
create-tag:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version-file: ".python-version"
- name: Install dependencies
run: pip install toml
- name: Extract version from pyproject.toml
id: get_version
run: |
version=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['version'])")
echo "version=$version" >> $GITHUB_OUTPUT
- name: Create Git tag if not exists
run: |
git fetch --tags
tag="v${{ steps.get_version.outputs.version }}"
if ! git rev-parse "$tag" >/dev/null 2>&1; then
git tag "$tag"
git push origin "$tag"
else
echo "Tag $tag already exists."
fi