-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hotfix: Merge auto-tag workflow with pypi
- Loading branch information
Showing
4 changed files
with
54 additions
and
62 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,48 @@ | ||
name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI | ||
|
||
on: push | ||
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 | ||
|
@@ -28,17 +65,15 @@ jobs: | |
path: dist/ | ||
|
||
publish-to-pypi: | ||
name: >- | ||
Publish Python 🐍 distribution 📦 to PyPI | ||
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes | ||
needs: | ||
- build | ||
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 # IMPORTANT: mandatory for trusted publishing | ||
id-token: write | ||
|
||
steps: | ||
- name: Download all the dists | ||
|
@@ -50,16 +85,13 @@ jobs: | |
uses: pypa/gh-action-pypi-publish@release/v1 | ||
|
||
github-release: | ||
name: >- | ||
Sign the Python 🐍 distribution 📦 with Sigstore | ||
and upload them to GitHub Release | ||
needs: | ||
- publish-to-pypi | ||
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 # IMPORTANT: mandatory for making GitHub Releases | ||
id-token: write # IMPORTANT: mandatory for sigstore | ||
contents: write | ||
id-token: write | ||
|
||
steps: | ||
- name: Download all the dists | ||
|
@@ -84,26 +116,23 @@ jobs: | |
- 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 }}' | ||
publish-to-testpypi: | ||
name: Publish Python 🐍 distribution 📦 to TestPyPI | ||
needs: | ||
- build | ||
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 # IMPORTANT: mandatory for trusted publishing | ||
id-token: write | ||
|
||
steps: | ||
- name: Download all the dists | ||
|
@@ -115,4 +144,4 @@ jobs: | |
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
repository-url: https://test.pypi.org/legacy/ | ||
skip_existing: true | ||
skip_existing: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters