From 293bb478d6825c49910ccc090464cc7093e523a6 Mon Sep 17 00:00:00 2001 From: David Gidwani Date: Sat, 9 Mar 2024 19:11:38 -0500 Subject: [PATCH] ci: :ferris_wheel: add publish workflow --- .github/workflows/publish.yml | 29 +++++++++++++++++++++++++++++ .github/workflows/release.yml | 18 +++++------------- 2 files changed, 34 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..1dd86ec --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,29 @@ +name: Publish + +on: + pull_request: + branches: + - main + types: [closed] + workflow_dispatch: + +jobs: + verify_branch: + runs-on: ubuntu-latest + if: github.event.pull_request.merged == true && github.event.pull_request.head.ref == ${{ vars.RELEASE_PR_BRANCH || 'create-pull-request/patch' }} + outputs: + should-publish: + steps: + - name: Publish to GitHub Releases + if: github.event_name == 'workflow_dispatch' + uses: python-semantic-release/upload-to-gh-release@main + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + tag: latest + + - name: Publish to PyPI + if: github.event_name == 'workflow_dispatch' + uses: pypa/gh-action-pypi-publish@release/v1 + with: + skip-existing: true + verbose: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f82920b..a431102 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -70,8 +70,10 @@ jobs: force: "patch" github_token: ${{ secrets.GITHUB_TOKEN }} root_options: "-v" + push: "false" - name: Create PR + id: cpr uses: peter-evans/create-pull-request@v4.0.2 if: steps.release.outputs.released == 'true' with: @@ -79,16 +81,6 @@ jobs: assignees: ${{ github.repository_owner }} title: "Release ${{ steps.release.outputs.version }}" - - name: Publish package distributions to GitHub Releases - if: github.event_name == 'workflow_dispatch' || steps.release.outputs.released == 'true' - uses: python-semantic-release/upload-to-gh-release@main - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - tag: ${{ steps.release.outputs.tag }} - - - name: Publish package distributions to PyPI - if: github.event_name == 'workflow_dispatch' || steps.release.outputs.released == 'true' - uses: pypa/gh-action-pypi-publish@release/v1 - with: - skip-existing: true - verbose: true + - name: Finalize + run: | + echo 🪄✨ PR created at: ${{ steps.cpr.outputs.pull-request-url }}