Skip to content

Commit 1ba7fd9

Browse files
committed
Set up workflow_dispatch and skips for trusted publishing
1 parent 5c7fa90 commit 1ba7fd9

File tree

1 file changed

+37
-24
lines changed

1 file changed

+37
-24
lines changed

.github/workflows/wheels.yml

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,14 @@ on:
1515
- maintenance/**
1616
push:
1717
branches:
18-
- main # FOR TESTING
19-
tags:
20-
- v*
18+
- main # FOR TESTING ONLY
2119
workflow_dispatch:
20+
inputs:
21+
environment:
22+
description: Which PyPI environment to upload to, if any
23+
required: true
24+
type: choice
25+
options: ["none", "testpypi", "pypi"]
2226

2327
concurrency:
2428
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
@@ -70,8 +74,6 @@ jobs:
7074
- buildplat: [ macos13, macosx_x86_64, openblas ]
7175
python: "cp314t"
7276

73-
env:
74-
IS_32_BIT: ${{ matrix.buildplat[1] == 'win32' }}
7577
steps:
7678
- name: Checkout numpy-release
7779
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -138,12 +140,12 @@ jobs:
138140
CIBW_BUILD: ${{ matrix.python }}-${{ matrix.buildplat[1] }}
139141
run: |
140142
python -m pip install cibuildwheel==3.1.0
141-
python -m cibuildwheel numpy-src --config-file cibuildwheel.toml --output-dir ./wheelhouse
143+
python -m cibuildwheel numpy-src --config-file cibuildwheel.toml --output-dir ./dist
142144
143145
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
144146
with:
145147
name: ${{ matrix.python }}-${{ matrix.buildplat[1] }}-${{ matrix.buildplat[2] }}
146-
path: ./wheelhouse/*.whl
148+
path: ./dist/*.whl
147149

148150
build_sdist:
149151
name: Build sdist
@@ -174,36 +176,47 @@ jobs:
174176
path: ./dist/*
175177

176178
testpypi-publish:
177-
name: Upload release to TestPyPI
178-
if: # TODO - add a release True/False? and on `main`?
179+
name: Publish release to TestPyPI
180+
if: github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'testpypi'
179181
needs: [build_wheels, build_sdist]
180182
runs-on: ubuntu-latest
181183
environment:
182-
name: pypi
183-
url: https://pypi.org/p/numpy
184+
name: testpypi
185+
url: https://test.pypi.org/p/numpy
184186
permissions:
185-
id-token: write
187+
id-token: write # mandatory for trusted publishing
186188
steps:
187-
# TODO: retrieve your distributions here
189+
- name: Download sdist and wheels
190+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v.4.3.0
191+
with:
192+
path: dist
188193

189-
- name: Publish package distributions to PyPI
190-
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4
191-
with:
192-
print-hash: true
194+
- name: Publish
195+
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4
196+
with:
197+
repository-url: https://test.pypi.org/legacy/
198+
skip-existing: true
199+
print-hash: true
200+
attestations: true
193201

194202
pypi-publish:
195-
name: Upload release to PyPI
203+
name: Publish release to PyPI
204+
if: github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'pypi'
196205
needs: [build_wheels, build_sdist]
197206
runs-on: ubuntu-latest
198207
environment:
199208
name: pypi
200209
url: https://pypi.org/p/numpy
201210
permissions:
202-
id-token: write
211+
id-token: write # mandatory for trusted publishing
203212
steps:
204-
# TODO: retrieve your distributions here
213+
- name: Download sdist and wheels
214+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v.4.3.0
215+
with:
216+
path: dist
205217

206-
- name: Publish package distributions to PyPI
207-
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4
208-
with:
209-
print-hash: true
218+
- name: Publish
219+
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4
220+
with:
221+
print-hash: true
222+
attestations: true

0 commit comments

Comments
 (0)