Skip to content

Commit

Permalink
hotfix: Merge auto-tag workflow with pypi
Browse files Browse the repository at this point in the history
  • Loading branch information
aelmiger committed Jul 17, 2024
1 parent bcf779c commit 315af54
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 62 deletions.
35 changes: 0 additions & 35 deletions .github/workflows/auto-tag.yaml

This file was deleted.

77 changes: 53 additions & 24 deletions .github/workflows/deploy_to_pypi.yaml
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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
2 changes: 0 additions & 2 deletions .github/workflows/integration_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name: Syclops Pipeline Test
on:
push:
branches: [ main ]
tags:
- 'v*' # This will match any tag starting with 'v'
pull_request:
branches: [ main ]

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ readme = "README.md"
requires-python = ">=3.8"
license = {text = "GPLv3"}

version = "1.3.6"
version = "1.3.7"

dynamic = ["dependencies"]

Expand Down

0 comments on commit 315af54

Please sign in to comment.