From f4137951327f1710e1ef5c55e89997f94ed12329 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Mon, 20 May 2024 20:05:49 -0400 Subject: [PATCH] ci: only publish pypi when release changes from pre-release to stable --- .github/workflows/CI.yml | 27 +-------------------- .github/workflows/update-pypi.yml | 39 +++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 26 deletions(-) create mode 100644 .github/workflows/update-pypi.yml diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index ac47619..8dd265c 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -152,37 +152,12 @@ jobs: echo "::endgroup::" - name: Upload artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: dist if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn` path: dist - publish: - name: Publish - if: >- - (github.event_name == 'push' && github.ref == 'refs/heads/master') || - (github.event_name == 'workflow_dispatch') - needs: - - setup_release - - build - runs-on: ubuntu-latest - environment: - name: publish - url: https://pypi.org/p/plexhints - permissions: - id-token: write - steps: - - name: Download dist artifacts - # this will be published to PyPI - uses: actions/download-artifact@v3 - with: - name: dist - path: dist - - - name: Publish to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 - - name: Create/Update GitHub Release if: ${{ needs.setup_release.outputs.publish_release == 'true' }} uses: LizardByte/create-release-action@v2024.520.193838 diff --git a/.github/workflows/update-pypi.yml b/.github/workflows/update-pypi.yml new file mode 100644 index 0000000..58019a4 --- /dev/null +++ b/.github/workflows/update-pypi.yml @@ -0,0 +1,39 @@ +--- +# Update pypi on release events. + +name: Update pypi + +on: + release: + types: [created, edited] + workflow_dispatch: + +concurrency: + group: "${{ github.workflow }}-${{ github.event.release.tag_name }}" + cancel-in-progress: true + +jobs: + update-pypi: + if: >- + !github.event.release.prerelease && !github.event.release.draft + runs-on: ubuntu-latest + environment: + name: publish + url: https://pypi.org/p/plexhints + permissions: + id-token: write + steps: + - name: Download release assets + id: download + uses: robinraju/release-downloader@v1.10 + with: + repository: "${{ github.repository }}" + tag: "${{ github.event.release.tag_name }}" + fileName: "*" + tarBall: false + zipBall: false + out-file-path: "dist" + extract: false + + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1