diff --git a/.github/workflows/auto-tag.yaml b/.github/workflows/auto-tag.yaml deleted file mode 100644 index 0fc788d..0000000 --- a/.github/workflows/auto-tag.yaml +++ /dev/null @@ -1,35 +0,0 @@ -on: - push: - branches: - - main - -jobs: - auto-tag: - runs-on: ubuntu-latest - 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: Check if tag exists - id: check_tag - run: | - if git rev-parse "${{ steps.get_version.outputs.VERSION }}" >/dev/null 2>&1; then - echo "TAG_EXISTS=true" >> $GITHUB_OUTPUT - else - echo "TAG_EXISTS=false" >> $GITHUB_OUTPUT - fi - - - name: Create and push tag - if: steps.check_tag.outputs.TAG_EXISTS == 'false' - run: | - git config user.name github-actions - git config user.email github-actions@github.com - git tag ${{ steps.get_version.outputs.VERSION }} - git push origin ${{ steps.get_version.outputs.VERSION }} diff --git a/.github/workflows/deploy_to_pypi.yaml b/.github/workflows/deploy_to_pypi.yaml index e1f1bd9..905355e 100644 --- a/.github/workflows/deploy_to_pypi.yaml +++ b/.github/workflows/deploy_to_pypi.yaml @@ -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 github-actions@github.com + 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,9 +116,6 @@ 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/** @@ -94,16 +123,16 @@ jobs: 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 \ No newline at end of file diff --git a/.github/workflows/integration_test.yaml b/.github/workflows/integration_test.yaml index 8ae1246..d396fc8 100644 --- a/.github/workflows/integration_test.yaml +++ b/.github/workflows/integration_test.yaml @@ -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 ] diff --git a/pyproject.toml b/pyproject.toml index ab06431..77059d2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,7 @@ readme = "README.md" requires-python = ">=3.8" license = {text = "GPLv3"} -version = "1.3.6" +version = "1.3.7" dynamic = ["dependencies"]