Skip to content

hotfix: Bump signing workflow version to dependency error #35

hotfix: Bump signing workflow version to dependency error

hotfix: Bump signing workflow version to dependency error #35

name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
auto-tag:
name: Create and push tag
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
outputs:
new_tag: ${{ steps.create_tag.outputs.new_tag }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get version from pyproject.toml
id: get_version
run: |
VERSION=$(grep '^version =' pyproject.toml | awk -F'"' '{print $2}')
echo "VERSION=v$VERSION" >> $GITHUB_OUTPUT
- name: Create and push tag
id: create_tag
run: |
if ! git rev-parse ${{ steps.get_version.outputs.VERSION }} >/dev/null 2>&1; then
git config user.name github-actions
git config user.email [email protected]
git tag ${{ steps.get_version.outputs.VERSION }}
git push origin ${{ steps.get_version.outputs.VERSION }}
echo "new_tag=true" >> $GITHUB_OUTPUT
else
echo "new_tag=false" >> $GITHUB_OUTPUT
fi
build:
name: Build distribution 📦
needs: [auto-tag]
runs-on: ubuntu-latest
if: >
github.event_name == 'pull_request' ||
(github.event_name == 'push' && needs.auto-tag.outputs.new_tag == 'true')
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install pypa/build
run: >-
python3 -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/
publish-to-pypi:
name: Publish Python 🐍 distribution 📦 to PyPI
needs: [auto-tag, build]
if: needs.auto-tag.outputs.new_tag == 'true'
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/syclops
permissions:
id-token: write
steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
github-release:
name: Sign and upload to GitHub Release
needs: [auto-tag, publish-to-pypi]
if: needs.auto-tag.outputs.new_tag == 'true'
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Sign the dists with Sigstore
uses: sigstore/[email protected]
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 }}'
publish-to-testpypi:
name: Publish Python 🐍 distribution 📦 to TestPyPI
needs: [auto-tag, build]
if: >
github.event_name == 'pull_request' ||
(github.event_name == 'push' && needs.auto-tag.outputs.new_tag == 'true')
runs-on: ubuntu-latest
environment:
name: testpypi
url: https://test.pypi.org/p/syclops
permissions:
id-token: write
steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
skip_existing: true