@@ -2,6 +2,8 @@ name: Build
22
33on :
44 push :
5+ tags :
6+ - " *"
57 branches :
68 - main
79 pull_request :
@@ -21,14 +23,15 @@ jobs:
2123 - name : Install dependencies
2224 run : |
2325 python -m pip install --upgrade pip
24- pip install 'poetry>=1.8,<1.9 '
26+ pip install 'poetry>=2.2.1,<2.3 '
2527 poetry check --lock
2628
2729 build :
2830 runs-on : ubuntu-latest
2931 strategy :
32+ fail-fast : false
3033 matrix :
31- python-version : ["3.9 ", "3.10 ", "3.11 ", "3.12 ", "3.13 "]
34+ python-version : ["3.10 ", "3.11 ", "3.12 ", "3.13 ", "3.14 "]
3235
3336 steps :
3437 - uses : actions/checkout@v1
@@ -39,12 +42,72 @@ jobs:
3942 - name : Install dependencies
4043 run : |
4144 python -m pip install --upgrade pip
42- pip install 'tox<5' tox-gh-actions 'poetry>=1.8,<1.9 '
45+ pip install 'tox<5' tox-gh-actions 'poetry>=2.2,<2.3 '
4346 - name : Test with tox
4447 run : tox
4548
4649 - name : Upload coverage to Codecov
47- if : matrix.python-version == 3.11
50+ if : matrix.python-version == 3.13
4851 uses : codecov/codecov-action@v2.1.0
4952 with :
5053 file : ./coverage.xml
54+
55+ # https://github.com/marketplace/actions/alls-green#why
56+ all-green :
57+ name : Are all checks green?
58+ if : always()
59+ needs :
60+ - poetry-lockfile-up-to-date
61+ - build
62+ runs-on : ubuntu-latest
63+
64+ steps :
65+ - name : Decide whether the needed jobs succeeded or failed
66+ uses : re-actors/alls-green@release/v1
67+ with :
68+ jobs : ${{ toJSON(needs) }}
69+
70+ check-tag :
71+ name : Check tag correctness
72+ runs-on : ubuntu-latest
73+ if : " startsWith(github.ref, 'refs/tags/v')"
74+ steps :
75+ - uses : actions/checkout@v4
76+ - run : |
77+ version=$(grep -E '^version\s*=' pyproject.toml | sed -E 's/^version\s*=\s*"([^"]+)".*/\1/')
78+
79+ tag="${GITHUB_REF_NAME}"
80+
81+ echo "Detected version in pyproject.toml: $version"
82+ echo "Detected tag name: $tag"
83+
84+ # Compare them
85+ if [ "v$version" != "$tag" ]; then
86+ echo "❌ Tag ($tag) does not match version in pyproject.toml ($version)"
87+ exit 1
88+ fi
89+
90+ echo "✅ Tag matches version. Proceeding with release..."
91+
92+ release :
93+ name : Release
94+ runs-on : ubuntu-latest
95+ if : " startsWith(github.ref, 'refs/tags/v')"
96+ needs : [all-green, check-tag]
97+ environment : PyPI
98+ permissions :
99+ id-token : write
100+ steps :
101+ - uses : actions/checkout@v1
102+ - name : Set up Python
103+ uses : actions/setup-python@v2
104+ with :
105+ python-version : ' 3.13'
106+ - name : Install dependencies
107+ run : |
108+ pip install 'poetry>=2.2,<2.3'
109+ - name : Build distribution
110+ run : |
111+ poetry build
112+ - name : Publish package to PyPI
113+ uses : pypa/gh-action-pypi-publish@release/v1
0 commit comments