fix: Fix Python release workflow

This commit is contained in:
Jon Grace-Cox
2024-12-30 10:47:57 -05:00
parent 93e9816fde
commit 44d6c67fb1

View File

@@ -8,7 +8,7 @@ on:
- "v*.*.*"
jobs:
release:
build:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
@@ -30,6 +30,23 @@ jobs:
run: |
python setup.py sdist bdist_wheel
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
publish-to-pypi:
name: Publish to PyPI
needs: build
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
environment:
name: pypi
url: https://pypi.org/p/anybadge
steps:
- name: Upload package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
@@ -44,6 +61,47 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Clean up
run: |
rm -rf dist
github-release:
name: >-
Sign the Python 🐍 distribution 📦 with Sigstore
and upload them to GitHub Release
needs:
- publish-to-pypi
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
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@v3.0.0
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 }}
# Upload to GitHub Release using the `gh` CLI.
# `dist/` contains the built packages, and the
# sigstore-produced signatures and certificates.
run: >-
gh release upload
"$GITHUB_REF_NAME" dist/**
--repo "$GITHUB_REPOSITORY"
- name: Cleanup
run: rm -rf dist/