Skip to content

Commit

Permalink
Simplify publish.yml to be triggered on GH Release creation
Browse files Browse the repository at this point in the history
  • Loading branch information
gwenwindflower committed Apr 7, 2024
1 parent 9de5a5f commit b14c221
Showing 1 changed file with 4 additions and 38 deletions.
42 changes: 4 additions & 38 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: Publish to PyPI

on:
push:
branches:
- main
release:
types: [created]

jobs:
build:
Expand All @@ -21,22 +20,21 @@ jobs:
- name: Build a binary wheel and a source tarball
run: python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/

publish:
name: Publish to PyPI
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
needs:
- build
runs-on: macos-latest
environment:
name: release
url: https://pypi.org/p/jaffle-shop-generator
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
id-token: write

steps:
- name: Download all the dists
Expand All @@ -46,35 +44,3 @@ jobs:
path: dist/
- name: Publish dist to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

github-release:
name: Publish GitHub Release
needs:
- publish-to-pypi
runs-on: macos-latest
permissions:
contents: write # IMPORTANT: mandatory for making GitHub Releases
id-token: write # IMPORTANT: mandatory for sigstore

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Sign the dists with Sigstore
uses: sigstore/gh-action-sigstore-python@v2
with:
inputs: |
./dist/*.tar.gz
./dist/*.whl
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
gh release create '${{ github.ref_name }}' --repo '${{ github.repository }}' --notes ""
- name: Upload artifact signatures to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
gh release upload '${{ github.ref_name }}' dist/** --repo '${{ github.repository }}'

0 comments on commit b14c221

Please sign in to comment.