-
Notifications
You must be signed in to change notification settings - Fork 38
46 lines (40 loc) · 1.41 KB
/
Copy pathpython-publish.yml
File metadata and controls
46 lines (40 loc) · 1.41 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
# Uploads a Python package to PyPI when a release is created.
#
# Authentication uses PyPI Trusted Publishing (OpenID Connect) rather than a stored API token:
# GitHub mints a short-lived credential for this workflow, so there is no long-lived secret to
# leak or to silently expire. The trusted publisher must be registered once on PyPI, under
# Manage project -> Publishing, matching owner/repository/workflow below.
# https://docs.pypi.org/trusted-publishers/
name: Upload Python Package
on:
release:
types: [created]
# Allows re-publishing a tag whose release-triggered run failed, without cutting a new version.
workflow_dispatch:
inputs:
ref:
description: 'Tag to build and publish (e.g. v0.3.0)'
required: true
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
# Required for Trusted Publishing; the job needs no repository secrets at all.
id-token: write
steps:
- uses: actions/checkout@v4
with:
# setuptools_scm derives the version from tags, so the full history must be present.
fetch-depth: 0
ref: ${{ inputs.ref || github.ref }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Build
run: |
python -m pip install --upgrade pip
pip install -U build
python -m build
- name: Publish
uses: pypa/gh-action-pypi-publish@release/v1