-
Notifications
You must be signed in to change notification settings - Fork 0
50 lines (46 loc) · 1.39 KB
/
publish-pypi.yml
File metadata and controls
50 lines (46 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
name: Publish to PyPI
on:
workflow_run:
workflows: ["Build wheels"]
types: [completed]
workflow_dispatch:
inputs:
tag:
description: "Release tag to publish (e.g. v0.5.26)"
required: true
jobs:
publish:
name: Upload to PyPI
runs-on: ubuntu-latest
# Only run if build-wheels succeeded (or manual dispatch)
if: >-
github.event_name == 'workflow_dispatch' ||
(github.event.workflow_run.conclusion == 'success' &&
startsWith(github.event.workflow_run.head_branch, 'v'))
permissions:
contents: read
id-token: write
steps:
- name: Determine tag
id: tag
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "tag=${{ github.event.inputs.tag }}" >> "$GITHUB_OUTPUT"
else
echo "tag=${{ github.event.workflow_run.head_branch }}" >> "$GITHUB_OUTPUT"
fi
- name: Download release assets
env:
GH_TOKEN: ${{ github.token }}
run: |
TAG="${{ steps.tag.outputs.tag }}"
echo "Downloading wheels for ${TAG}..."
mkdir -p dist
gh release download "${TAG}" \
--repo "${{ github.repository }}" \
--dir dist \
--pattern "*.whl"
ls -la dist/
- uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/