Skip to content

Commit 4c9e313

Browse files
authored
Make python publish a separate job (#69)
1 parent 92c5cb9 commit 4c9e313

File tree

5 files changed

+52
-36
lines changed

5 files changed

+52
-36
lines changed

README.md

Lines changed: 48 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -310,27 +310,56 @@ Push the commit and tag to the source branch unless `dry_run` is set.
310310
dry_run: ${{ inputs.dry_run }}
311311
```
312312

313-
### Publish
313+
### Post-publish
314314

315-
Handles tasks related to publishing Python packages, including
316-
signing `dist` file and publishing the `dist` files to PyPI.
315+
To be run after separately publishing the [Python package](https://github.com/pypa/gh-action-pypi-publish#trusted-publishing).
316+
Handles follow-up tasks related to publishing Python packages, including
317+
signing `dist` files and uploading report assets to S3.
317318
It will also push the following (dev) version to the source branch.
318319
It will create a draft GitHub release and attach the signature files.
319-
Finally, it will publish a report to the appropriate S3 bucket.
320-
If `dry_run` is set, nothing will be published or pushed.
320+
If `dry_run` is set, nothing will be pushed.
321321

322-
```yaml
323-
- name: Setup
324-
uses: mongodb-labs/drivers-github-tools/setup@v2
325-
with:
326-
...
322+
The jobs should look something like:
327323

328-
- uses: mongodb-labs/drivers-github-tools/python/publish@v2
329-
with:
330-
version: ${{ inputs.version }}
331-
following_version: ${{ inputs.following_version }}
332-
version_bump_script: ./.github/scripts/bump-version.sh
333-
product_name: winkerberos
334-
token: ${{ github.token }}
335-
dry_run: ${{ inputs.dry_run }}
336-
```
324+
```yaml
325+
publish:
326+
name: Upload release to PyPI
327+
runs-on: ubuntu-latest
328+
environment: release
329+
permissions:
330+
id-token: write
331+
steps:
332+
- name: Download all the dists
333+
uses: actions/download-artifact@v4
334+
with:
335+
name: all-dist-${{ github.run_id }}
336+
path: dist/
337+
- name: Publish package distributions to PyPI
338+
if: inputs.dry_run == 'false'
339+
uses: pypa/gh-action-pypi-publish@release/v1
340+
341+
post-publish:
342+
needs: [publish]
343+
name: Handle post-publish actions
344+
runs-on: ubuntu-latest
345+
environment: release
346+
permissions:
347+
id-token: write
348+
contents: write
349+
attestations: write
350+
security-events: write
351+
steps:
352+
- name: Setup
353+
uses: mongodb-labs/drivers-github-tools/setup@v2
354+
with:
355+
...
356+
357+
- uses: mongodb-labs/drivers-github-tools/python/post-publish@v2
358+
with:
359+
version: ${{ inputs.version }}
360+
following_version: ${{ inputs.following_version }}
361+
version_bump_script: ./.github/scripts/bump-version.sh
362+
product_name: winkerberos
363+
token: ${{ github.token }}
364+
dry_run: ${{ inputs.dry_run }}
365+
```

python/publish/action.yml renamed to python/post-publish/action.yml

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

2-
name: Publish Python
3-
description: Publish Assets and Report
2+
name: Python Post-Publish
3+
description: Perform post-release operations for Python Libraries
44
inputs:
55
version:
66
description: The published version
@@ -76,26 +76,14 @@ runs:
7676
- name: Run GitHub Publish script
7777
shell: bash
7878
id: publish-script
79-
run: ${{ github.action_path }}/publish.sh
79+
run: ${{ github.action_path }}/post-publish.sh
8080
env:
8181
GH_TOKEN: ${{ inputs.token }}
8282
VERSION: ${{ inputs.version }}
8383
TAG_TEMPLATE: ${{ inputs.tag_template }}
8484
PRODUCT_NAME: ${{ inputs.product_name }}
8585
DRY_RUN: ${{ inputs.dry_run }}
8686
FOLLOWING_VERSION: ${{ inputs.following_version }}
87-
# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/#publishing-the-distribution-to-pypi
88-
- name: Publish distribution 📦 to PyPI
89-
if: inputs.dry_run == 'false'
90-
# Pinned due to https://github.com/pypa/gh-action-pypi-publish/issues/290
91-
uses: pypa/[email protected]
92-
with:
93-
repository-url: ${{ inputs.repository_url }}
94-
- name: Do Not Publish distribution 📦 to PyPI on Dry Run
95-
if: inputs.dry_run == 'true'
96-
shell: bash
97-
run: |
98-
echo "Dry run, not uploading to PyPI" >> $GITHUB_STEP_SUMMARY
9987
- uses: actions/attest-build-provenance@v1
10088
if: inputs.dry_run == 'false'
10189
with:
File renamed without changes.

python/pre-publish/action.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ runs:
3434
- name: Install hatch
3535
shell: bash
3636
working-directory: ${{ inputs.working_directory }}
37-
# TODO: remove when #62 is fixed.
38-
run: pipx install "hatch<1.27"
37+
run: pipx install hatch
3938
- name: Check if we should push changes
4039
shell: bash
4140
run: |

0 commit comments

Comments
 (0)