Skip to content

Commit a9784d6

Browse files
committed
try to fix test publish
1 parent f0b2126 commit a9784d6

1 file changed

Lines changed: 40 additions & 9 deletions

File tree

.github/workflows/publish.yml

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,16 @@ jobs:
117117
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
118118
path: ./wheelhouse/*.whl
119119

120-
upload_all:
121-
name: Upload distributions
120+
upload_testpypi:
121+
name: Upload to TestPyPI
122122
needs:
123123
- build_wheels
124124
- build_sdist
125125
if: >-
126126
github.event_name == 'workflow_dispatch'
127127
|| (github.event_name == 'push' && github.ref == 'refs/heads/master')
128-
|| github.event_name == 'release'
129-
environment: pypi
128+
|| (github.event_name == 'release' && github.event.release.prerelease)
129+
environment: testpypi
130130
permissions:
131131
id-token: write
132132
runs-on: ubuntu-latest
@@ -155,12 +155,43 @@ jobs:
155155
PY
156156
157157
- uses: pypa/gh-action-pypi-publish@release/v1
158-
if: >-
159-
github.event_name == 'workflow_dispatch'
160-
|| (github.event_name == 'push' && github.ref == 'refs/heads/master')
161-
|| (github.event_name == 'release' && github.event.release.prerelease)
162158
with:
163159
repository-url: https://test.pypi.org/legacy/
160+
skip-existing: true
161+
verbose: true
162+
163+
upload_pypi:
164+
name: Upload to PyPI
165+
needs:
166+
- build_wheels
167+
- build_sdist
168+
if: github.event_name == 'release' && !github.event.release.prerelease
169+
environment: pypi
170+
permissions:
171+
id-token: write
172+
runs-on: ubuntu-latest
173+
174+
steps:
175+
- uses: actions/download-artifact@v4
176+
with:
177+
pattern: cibw-*
178+
path: dist
179+
merge-multiple: true
180+
181+
- name: Reject local versions in upload artifacts
182+
run: |
183+
python - <<'PY'
184+
from pathlib import Path
185+
files = [path.name for path in Path("dist").glob("*") if path.is_file()]
186+
bad = [name for name in files if "+" in name]
187+
if bad:
188+
joined = "\n".join(f" - {name}" for name in bad)
189+
raise SystemExit(
190+
"Refusing to upload artifacts with local version identifiers:\n"
191+
f"{joined}\n"
192+
"Configure setuptools_scm local_scheme to drop local version suffixes."
193+
)
194+
print("Artifact version check passed.")
195+
PY
164196
165197
- uses: pypa/gh-action-pypi-publish@release/v1
166-
if: github.event_name == 'release' && !github.event.release.prerelease

0 commit comments

Comments
 (0)