Skip to content

Commit 6ae27e3

Browse files
ci: publish PyPI from release-please on master (#1169)
Co-authored-by: MilesCranmerBot <milescranmerbot@users.noreply.github.com> Co-authored-by: Miles Cranmer <miles.cranmer@gmail.com>
1 parent cdee919 commit 6ae27e3

2 files changed

Lines changed: 56 additions & 11 deletions

File tree

.github/workflows/pypi_deploy.yml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
name: Deploy PyPI
22
on:
3-
push:
4-
tags:
5-
- 'v*.*.*'
63
workflow_dispatch:
4+
inputs:
5+
publish_ref:
6+
description: Tag or ref to publish manually (for backfills, e.g. v1.5.10)
7+
required: true
8+
type: string
79

810
jobs:
911
pypi:
@@ -12,26 +14,29 @@ jobs:
1214
name: pypi
1315
url: https://pypi.org/p/pysr
1416
permissions:
17+
contents: read
1518
id-token: write
1619
steps:
17-
- name: "Checkout"
20+
- name: Checkout
1821
uses: actions/checkout@v6
19-
- name: "Set up Python"
22+
with:
23+
ref: ${{ inputs.publish_ref }}
24+
- name: Set up Python
2025
uses: actions/setup-python@v6
2126
with:
2227
python-version: 3.10.8
23-
- name: "Install building tools"
28+
- name: Install building tools
2429
run: pip install build
25-
- name: "Build package"
30+
- name: Build package
2631
run: python -m build
27-
- name: "Publish distribution 📦 to Test PyPI"
32+
- name: Publish distribution 📦 to Test PyPI
2833
uses: pypa/gh-action-pypi-publish@release/v1
2934
with:
3035
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
3136
repository-url: https://test.pypi.org/legacy/
3237
skip-existing: true
3338
verbose: true
34-
- name: "Publish distribution 📦 to PyPI"
39+
- name: Publish distribution 📦 to PyPI
3540
uses: pypa/gh-action-pypi-publish@release/v1
3641
with:
3742
password: ${{ secrets.PYPI_API_TOKEN }}

.github/workflows/release-please.yml

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,51 @@ permissions:
1313
jobs:
1414
release-please:
1515
runs-on: ubuntu-latest
16+
outputs:
17+
release_created: ${{ steps.release.outputs.release_created }}
18+
tag_name: ${{ steps.release.outputs.tag_name }}
19+
sha: ${{ steps.release.outputs.sha }}
1620
steps:
17-
- uses: googleapis/release-please-action@v4
21+
- id: release
22+
uses: googleapis/release-please-action@v4
1823
with:
19-
command: manifest
2024
token: ${{ secrets.GITHUB_TOKEN }}
2125
target-branch: master
2226
config-file: release-please-config.json
2327
manifest-file: .release-please-manifest.json
28+
29+
publish-pypi:
30+
needs: release-please
31+
if: ${{ needs.release-please.outputs.release_created == 'true' }}
32+
runs-on: ubuntu-latest
33+
environment:
34+
name: pypi
35+
url: https://pypi.org/p/pysr
36+
permissions:
37+
contents: read
38+
id-token: write
39+
steps:
40+
- name: Checkout released revision
41+
uses: actions/checkout@v6
42+
with:
43+
ref: ${{ needs.release-please.outputs.sha }}
44+
- name: Set up Python
45+
uses: actions/setup-python@v6
46+
with:
47+
python-version: 3.10.8
48+
- name: Install building tools
49+
run: pip install build
50+
- name: Build package
51+
run: python -m build
52+
- name: Publish distribution 📦 to Test PyPI
53+
uses: pypa/gh-action-pypi-publish@release/v1
54+
with:
55+
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
56+
repository-url: https://test.pypi.org/legacy/
57+
skip-existing: true
58+
verbose: true
59+
- name: Publish distribution 📦 to PyPI
60+
uses: pypa/gh-action-pypi-publish@release/v1
61+
with:
62+
password: ${{ secrets.PYPI_API_TOKEN }}
63+
verbose: true

0 commit comments

Comments
 (0)