Skip to content

Commit 993c5ee

Browse files
committed
CI: set up workflow_dispatch and skips for trusted publishing
1 parent 4014458 commit 993c5ee

File tree

1 file changed

+40
-22
lines changed

1 file changed

+40
-22
lines changed

.github/workflows/wheels.yml

Lines changed: 40 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,15 @@ on:
1414
- main
1515
- maintenance/**
1616
push:
17-
tags:
18-
- v*
17+
branches:
18+
- main # FOR TESTING ONLY
1919
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"]
2026

2127
concurrency:
2228
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
@@ -68,7 +74,8 @@ jobs:
6874
python: "cp314t"
6975

7076
env:
71-
IS_32_BIT: ${{ matrix.buildplat[1] == 'win32' }}
77+
IS_32_BIT: ${{ matrix.buildplat[1] == 'win32' }} # used in a cibw_*.sh script
78+
7279
steps:
7380
- name: Checkout numpy-release
7481
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -135,12 +142,12 @@ jobs:
135142
CIBW_BUILD: ${{ matrix.python }}-${{ matrix.buildplat[1] }}
136143
run: |
137144
python -m pip install cibuildwheel==3.1.0
138-
python -m cibuildwheel numpy-src --config-file cibuildwheel.toml --output-dir ./wheelhouse
145+
python -m cibuildwheel numpy-src --config-file cibuildwheel.toml --output-dir ./dist
139146
140147
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
141148
with:
142149
name: ${{ matrix.python }}-${{ matrix.buildplat[1] }}-${{ matrix.buildplat[2] }}
143-
path: ./wheelhouse/*.whl
150+
path: ./dist/*.whl
144151

145152
build_sdist:
146153
name: Build sdist
@@ -171,36 +178,47 @@ jobs:
171178
path: ./dist/*
172179

173180
testpypi-publish:
174-
name: Upload release to TestPyPI
175-
if: # TODO - add a release True/False? and on `main`?
181+
name: Publish release to TestPyPI
182+
if: github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'testpypi'
176183
needs: [build_wheels, build_sdist]
177184
runs-on: ubuntu-latest
178185
environment:
179-
name: pypi
180-
url: https://pypi.org/p/numpy
186+
name: testpypi
187+
url: https://test.pypi.org/p/numpy
181188
permissions:
182-
id-token: write
189+
id-token: write # mandatory for trusted publishing
183190
steps:
184-
# TODO: retrieve your distributions here
191+
- name: Download sdist and wheels
192+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v.4.3.0
193+
with:
194+
path: dist
185195

186-
- name: Publish package distributions to PyPI
187-
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4
188-
with:
189-
print-hash: true
196+
- name: Publish
197+
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4
198+
with:
199+
repository-url: https://test.pypi.org/legacy/
200+
skip-existing: true
201+
print-hash: true
202+
attestations: true
190203

191204
pypi-publish:
192-
name: Upload release to PyPI
205+
name: Publish release to PyPI
206+
if: github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'pypi'
193207
needs: [build_wheels, build_sdist]
194208
runs-on: ubuntu-latest
195209
environment:
196210
name: pypi
197211
url: https://pypi.org/p/numpy
198212
permissions:
199-
id-token: write
213+
id-token: write # mandatory for trusted publishing
200214
steps:
201-
# TODO: retrieve your distributions here
215+
- name: Download sdist and wheels
216+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v.4.3.0
217+
with:
218+
path: dist
202219

203-
- name: Publish package distributions to PyPI
204-
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4
205-
with:
206-
print-hash: true
220+
- name: Publish
221+
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4
222+
with:
223+
print-hash: true
224+
attestations: true

0 commit comments

Comments
 (0)