-
Notifications
You must be signed in to change notification settings - Fork 19
50 lines (42 loc) · 1.34 KB
/
release-2-publish.yml
File metadata and controls
50 lines (42 loc) · 1.34 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: Release Step 2 - Publish to PyPI
run-name: publish to pypi
on:
workflow_run:
workflows: ["Release Step 1 - Release on GitHub"] # Must match name exactly
types: [completed]
workflow_dispatch:
inputs:
ref:
description: "Branch or tag to publish"
default: "main"
required: false
jobs:
pypi-publish:
# Only run if Step 1 was successful, or if triggered manually
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
name: Build and publish Python package
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write # Required for PyPI Trusted Publishing
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
# Use branch from trigger, or default to main
ref: ${{ github.event.workflow_run.head_branch || inputs.ref || 'main' }}
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: "pyproject.toml"
- name: Build package
run: uv build
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
print-hash: true