Skip to content

Commit 81e7651

Browse files
authored
build: automate publish on release (#229)
1 parent 2adf52f commit 81e7651

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

.github/workflows/release-2-publish.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,35 @@
11
name: Release Step 2 - Publish to PyPI
2-
run-name: publish to pypi ${{ github.event.release.tag_name }}
2+
run-name: publish to pypi
33

44
on:
5-
release:
6-
types: [published]
5+
workflow_run:
6+
workflows: ["Release Step 1 - Release on GitHub"] # Must match name exactly
7+
types: [completed]
8+
workflow_dispatch:
9+
inputs:
10+
ref:
11+
description: 'Branch or tag to publish'
12+
default: 'main'
13+
required: false
714

815
jobs:
916
pypi-publish:
17+
# Only run if Step 1 was successful, or if triggered manually
18+
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
1019
name: Build and publish Python package
1120
runs-on: ubuntu-latest
1221
environment: release
1322

14-
# Required for PyPI Trusted Publishing
1523
permissions:
16-
id-token: write
24+
id-token: write # Required for PyPI Trusted Publishing
1725
contents: read
1826

1927
steps:
2028
- name: Checkout repository
2129
uses: actions/checkout@v4
2230
with:
23-
ref: ${{ github.event.release.tag_name }}
31+
# Use branch from trigger, or default to main
32+
ref: ${{ github.event.workflow_run.head_branch || inputs.ref || 'main' }}
2433

2534
- name: Install uv
2635
uses: astral-sh/setup-uv@v5

0 commit comments

Comments
 (0)