Skip to content

Commit 9b2f1ec

Browse files
Prepare release.yml for prod PyPI publish (#29)
* don't trigger GHAs on changes to unrelated GHA ymls * Prepare `release.yml` for prod PyPI publish
1 parent 158a7c8 commit 9b2f1ec

File tree

3 files changed

+61
-25
lines changed

3 files changed

+61
-25
lines changed

.github/workflows/python-tiledbsoma-ml.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ on:
99
- "scripts/**"
1010
- "notebooks/**"
1111
- "www/**"
12+
- ".github/**"
13+
- "!.github/workflows/python-tiledbsoma-ml.yml"
1214
push:
1315
branches: [main]
1416
paths-ignore:
@@ -17,6 +19,8 @@ on:
1719
- "scripts/**"
1820
- "notebooks/**"
1921
- "www/**"
22+
- ".github/**"
23+
- "!.github/workflows/python-tiledbsoma-ml.yml"
2024
workflow_dispatch:
2125

2226
jobs:

.github/workflows/python-tilledbsoma-ml-compat.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ on:
99
- "scripts/**"
1010
- "notebooks/**"
1111
- "www/**"
12+
- ".github/**"
13+
- "!.github/workflows/python-tiledbsoma-ml.yml"
1214
push:
1315
branches: [main]
1416
paths-ignore:
@@ -17,6 +19,8 @@ on:
1719
- "scripts/**"
1820
- "notebooks/**"
1921
- "www/**"
22+
- ".github/**"
23+
- "!.github/workflows/python-tiledbsoma-ml.yml"
2024
workflow_dispatch:
2125

2226
jobs:

.github/workflows/release.yml

Lines changed: 53 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,63 @@
1-
name: Release
1+
# New release tags trigger this workflow to publish to test.pypi.org.
2+
# If that looks good, a `workflow_dispatch` can be used to publish to pypi.org (with `prod-pypi` set to 'true').
3+
name: Publish to PyPI
24
on:
5+
push:
6+
tags:
7+
- 'v[0-9]+*'
38
workflow_dispatch:
49
inputs:
5-
tag:
6-
description: 'The tag version to release (e.g., v1.0.0)'
7-
required: true
8-
default: 'v0.1.0alpha'
9-
environment:
10-
description: 'PyPI environment to release to (test or production)'
11-
required: true
12-
default: 'test'
13-
10+
prod-pypi:
11+
type: boolean
12+
description: 'Publish to pypi.org (default: test.pypi.org)'
13+
ref:
14+
description: 'Git ref to checkout, build, and publish'
15+
verbose:
16+
type: boolean
17+
description: 'Enable debug output from pypa/gh-action-pypi-publish'
1418
jobs:
15-
pypi-publish:
16-
name: upload release to PyPI
19+
build:
20+
name: Build package
1721
runs-on: ubuntu-latest
18-
environment: pypi
22+
steps:
23+
- uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
ref: ${{ inputs.ref || '' }}
27+
- uses: actions/setup-python@v5
28+
with:
29+
python-version: '3.11.11'
30+
- name: Build package
31+
run: |
32+
pip install build
33+
python -m build
34+
ls -l dist
35+
- name: Upload distributions
36+
uses: actions/upload-artifact@v4
37+
with:
38+
name: python-package-distributions
39+
path: dist/
40+
retention-days: 1
41+
publish:
42+
name: Upload release to ${{ inputs.prod-pypi != true && 'test ' || '' }}PyPI
43+
needs: build
44+
runs-on: ubuntu-latest
45+
environment:
46+
name: pypi
47+
url: https://${{ inputs.prod-pypi != true && 'test.' || '' }}pypi.org/p/tiledbsoma_ml # Displayed in GHA UI
1948
permissions:
2049
id-token: write
2150
steps:
22-
- name: Setup Python
23-
uses: actions/setup-python@v5
24-
- name: Checkout
25-
uses: actions/checkout@v4
26-
- name: Build package
27-
run: pip install build && python -m build && ls -l dist
28-
- name: Publish package distributions to Test PyPI
29-
uses: pypa/gh-action-pypi-publish@release/v1
30-
continue-on-error: true
51+
- name: Print inputs
52+
run: |
53+
echo "Inputs: ${{ toJSON(github.event.inputs) }}"
54+
- name: Download distributions
55+
uses: actions/download-artifact@v4
3156
with:
32-
repository_url: https://test.pypi.org/legacy/
33-
- name: Publish package distributions to PyPI
34-
if: "!github.event.release.prerelease"
57+
name: python-package-distributions
58+
path: dist/
59+
- name: Publish package distributions to ${{ inputs.prod-pypi != true && 'test ' || '' }}PyPI
3560
uses: pypa/gh-action-pypi-publish@release/v1
61+
with:
62+
repository-url: ${{ inputs.prod-pypi != true && 'https://test.pypi.org/legacy/' || '' }}
63+
verbose: ${{ inputs.verbose }}

0 commit comments

Comments
 (0)