Skip to content

Commit 8d42781

Browse files
committed
add wheel publish job
1 parent 12031a5 commit 8d42781

1 file changed

Lines changed: 41 additions & 5 deletions

File tree

.github/workflows/release.yml

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ on:
2525
build-ctk-ver:
2626
type: string
2727
required: true
28+
wheel-dst:
29+
description: "Which wheel index to publish to?"
30+
required: true
31+
type: choice
32+
options:
33+
- testpypi
34+
- pypi
2835
#print_tags:
2936
# description: 'True to print to STDOUT'
3037
# required: true
@@ -38,11 +45,6 @@ jobs:
3845
check-tag:
3946
runs-on: ubuntu-latest
4047
steps:
41-
- name: Checkout ${{ github.event.repository.name }}
42-
uses: actions/checkout@v4
43-
with:
44-
fetch-depth: 0
45-
4648
- name: Check if draft exists for the tag
4749
env:
4850
GH_TOKEN: ${{ github.token }}
@@ -103,3 +105,37 @@ jobs:
103105
./.github/workflows/release-upload.yml
104106
with:
105107
git-tag: ${{ inputs.git-tag }}
108+
109+
publish-wheels:
110+
name: Publish wheels
111+
runs-on: ubuntu-latest
112+
needs:
113+
- check-tag
114+
environment:
115+
name: ${{ inputs.wheel-dst }}
116+
url: https://${{ (inputs.wheel-dst == 'testpypi' && 'test.') || '' }}pypi.org/p/${{ inputs.component }}/
117+
permissions:
118+
id-token: write
119+
steps:
120+
- name: Download component wheels
121+
env:
122+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
123+
run: |
124+
gh run download ${{ inputs.run-id }} -p "${{ inputs.component }}*" -R ${{ github.repository }}
125+
mkdir dist
126+
for p in "${{ inputs.component }}*"; do
127+
mv ${p}/*.whl dist/
128+
done
129+
rmdir "${{ inputs.component }}*"
130+
131+
- name: Publish package distributions to PyPI
132+
if: ${{ inputs.wheel-dst == 'pypi' }}
133+
uses: pypa/gh-action-pypi-publish@release/v1
134+
135+
- name: Publish package distributions to TestPyPI
136+
if: ${{ inputs.wheel-dst == 'testpypi' }}
137+
uses: pypa/gh-action-pypi-publish@release/v1
138+
with:
139+
repository-url: https://test.pypi.org/legacy/
140+
141+
# TODO: add another job to make the release leave the draft state?

0 commit comments

Comments
 (0)