-
Notifications
You must be signed in to change notification settings - Fork 1.1k
64 lines (52 loc) · 1.8 KB
/
Copy pathpublish_to_pypi.yml
File metadata and controls
64 lines (52 loc) · 1.8 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
name: Publish to PyPI
on:
release:
types: [created] # Run when you click "Publish release"
workflow_dispatch: # ... or run it manually from the Actions tab
permissions:
contents: read
jobs:
release-build:
runs-on: ubuntu-latest
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Set up Python 3.13
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: "3.13"
cache: pip
cache-dependency-path: pyproject.toml
- name: Build package
run: |
python -m pip install --upgrade pip
python -m pip install build twine
python -m build
twine check dist/*
- name: Upload dist artefact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: dist
path: dist/
# Publish to PyPI (only if "dist/" succeeded)
pypi-publish:
needs: release-build
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write # OIDC token for trusted publishing
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
with:
name: dist
path: dist/
- uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # release/v1
with:
verbose: true