Skip to content

Commit c55c196

Browse files
committed
chore: automatically set version from git tag
1 parent 906303b commit c55c196

File tree

2 files changed

+30
-20
lines changed

2 files changed

+30
-20
lines changed

.github/workflows/publish.yml

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ name: Publish to PyPI
33
on:
44
push:
55
tags:
6-
- 'v*' # Triggers on tags like v1.0.0, v1.2.3, etc.
6+
- "*" # Triggers on tags like v1.0.0, v1.2.3, etc.
77

88
permissions:
9-
id-token: write # IMPORTANT: mandatory for trusted publishing
9+
id-token: write # IMPORTANT: mandatory for trusted publishing
1010

1111
jobs:
1212
build:
@@ -16,20 +16,30 @@ jobs:
1616
name: pypi
1717
url: https://pypi.org/p/laygo
1818
steps:
19-
- uses: actions/checkout@v4
20-
21-
- name: Set up Python
22-
uses: actions/setup-python@v5
23-
with:
24-
python-version: "3.12"
25-
26-
- name: Install uv
27-
uses: astral-sh/setup-uv@v4
28-
with:
29-
enable-cache: true
30-
31-
- name: Build package
32-
run: uv build
33-
34-
- name: Publish to PyPI
35-
uses: pypa/gh-action-pypi-publish@release/v1
19+
- uses: actions/checkout@v4
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: "3.12"
25+
26+
- name: Install uv
27+
uses: astral-sh/setup-uv@v4
28+
with:
29+
enable-cache: true
30+
31+
- name: Extract version from tag
32+
id: version
33+
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
34+
35+
- name: Update version in __init__.py
36+
run: |
37+
sed -i 's/VERSION_NUMBER/${{ steps.version.outputs.VERSION }}/g' laygo/__init__.py
38+
echo "Updated version to ${{ steps.version.outputs.VERSION }}"
39+
cat laygo/__init__.py
40+
41+
- name: Build package
42+
run: uv build
43+
44+
- name: Publish to PyPI
45+
uses: pypa/gh-action-pypi-publish@release/v1

laygo/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Laygo - A lightweight Python library for building resilient, in-memory data pipelines
33
"""
44

5-
__version__ = "0.1.1"
5+
__version__ = "VERSION_NUMBER"
66

77
from .errors import ErrorHandler
88
from .helpers import PipelineContext

0 commit comments

Comments
 (0)