Skip to content

Commit a06f384

Browse files
committed
CI: Publish each master commit with a unique version on TestPyPI
This follows commit 7d52df7 "CI: Ignore version duplicates when publishing to TestPyPI" with a better design: - Only publish builds from `master` branch on TestPyPI. - Version every non-tag commit with a `.devN` suffix, e.g. `1.36.2.dev1`. This prevents duplicates on TestPyPI. - `twine check` built packages. See discussion at #721 (comment) for more details.
1 parent cd96692 commit a06f384

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

.github/workflows/publish.yaml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,28 @@ jobs:
88
build:
99
name: Build distribution package
1010
runs-on: ubuntu-latest
11-
1211
steps:
1312
- uses: actions/checkout@v4
1413
with:
1514
persist-credentials: false
15+
- name: Fetch tags
16+
run: git fetch --prune --unshallow --tags
1617
- name: Set up Python
1718
uses: actions/setup-python@v5
1819
with:
1920
python-version: "3.x"
2021
- name: Install pypa/build
2122
run: python -m pip install --user build
23+
- name: Set unique version for non-tag builds
24+
if: ${{ ! startsWith(github.ref, 'refs/tags/') }}
25+
run: # add '.devN' to version
26+
sed -i
27+
"/^APP_VERSION = /s/'$/.dev$(git describe --tags | cut -d- -f2)'/"
28+
yamllint/__init__.py
2229
- name: Build a binary wheel and a source tarball
2330
run: python -m build
31+
- name: Twine check the distribution packages
32+
run: python -Im twine check --strict dist/*
2433
- name: Store the distribution packages
2534
uses: actions/upload-artifact@v4
2635
with:
@@ -29,6 +38,7 @@ jobs:
2938

3039
publish-to-testpypi:
3140
name: Publish distribution package to TestPyPI
41+
if: github.ref == 'refs/heads/master'
3242
needs: build
3343
runs-on: ubuntu-latest
3444
environment:
@@ -46,7 +56,6 @@ jobs:
4656
uses: pypa/gh-action-pypi-publish@release/v1
4757
with:
4858
repository-url: https://test.pypi.org/legacy/
49-
skip-existing: true
5059

5160
publish-to-pypi:
5261
name: Publish distribution package to PyPI

0 commit comments

Comments
 (0)