Skip to content

Commit a419d40

Browse files
author
evgenii
committed
CI: add Trusted Publishing job to wheels workflow (#61669)
1 parent 35b0d1d commit a419d40

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

.github/workflows/publish.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Release – upload to TestPyPI with Trusted Publishing
2+
3+
on:
4+
push:
5+
tags: ["v*"] # fires only on tag pushes
6+
workflow_dispatch:
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
environment:
12+
name: testpypi
13+
permissions:
14+
id-token: write
15+
contents: read
16+
17+
steps:
18+
- uses: actions/download-artifact@v4
19+
with:
20+
name: dist
21+
path: dist
22+
23+
- name: Publish to TestPyPI (Trusted Publishing)
24+
uses: pypa/gh-action-pypi-publish@release/v1
25+
with:
26+
repository-url: https://test.pypi.org/legacy/

.github/workflows/wheels.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,3 +219,40 @@ jobs:
219219
source ci/upload_wheels.sh
220220
set_upload_vars
221221
upload_wheels
222+
223+
# ---------------------------------------------------------------
224+
# PUBLISH – upload all wheels & sdist to Test PyPI via OIDC
225+
# ---------------------------------------------------------------
226+
publish:
227+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
228+
needs:
229+
- build_sdist
230+
- build_wheels
231+
runs-on: ubuntu-latest
232+
233+
environment:
234+
name: testpypi # ← keep for dry-run; change to pypi before PR
235+
permissions:
236+
id-token: write # OIDC token for Trusted Publishing
237+
contents: read
238+
239+
steps:
240+
# 1. Pull every artifact produced by the two upstream jobs
241+
- name: Download all artifacts
242+
uses: actions/download-artifact@v4
243+
with:
244+
path: dist # all files land in ./dist/**
245+
246+
# 2. Move wheels & sdist into a flat 'upload' dir (action expects that)
247+
- name: Collect files
248+
run: |
249+
mkdir -p upload
250+
find dist -name '*.whl' -exec mv {} upload/ \;
251+
find dist -name '*.tar.gz' -exec mv {} upload/ \;
252+
253+
# 3. Publish to **Test PyPI** using Trusted Publishing
254+
- name: Publish to TestPyPI (Trusted Publishing)
255+
uses: pypa/gh-action-pypi-publish@release/v1
256+
with:
257+
repository-url: https://test.pypi.org/legacy/
258+
packages-dir: upload

0 commit comments

Comments
 (0)