From 44d6c67fb17cffe2d4ed214d380dc9c919610a13 Mon Sep 17 00:00:00 2001 From: Jon Grace-Cox <30441316+jongracecox@users.noreply.github.com> Date: Mon, 30 Dec 2024 10:47:57 -0500 Subject: [PATCH] fix: Fix Python release workflow --- .github/workflows/python-package.yaml | 66 +++++++++++++++++++++++++-- 1 file changed, 62 insertions(+), 4 deletions(-) diff --git a/.github/workflows/python-package.yaml b/.github/workflows/python-package.yaml index 8b70933..07d7da3 100644 --- a/.github/workflows/python-package.yaml +++ b/.github/workflows/python-package.yaml @@ -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/