From 0ce75f0e1d95de0055b76ae056dd250d36754bf3 Mon Sep 17 00:00:00 2001 From: "Schmieder, Jacob" Date: Fri, 30 Aug 2024 08:34:09 +0000 Subject: [PATCH] updated conditon to be triggert on. Adjusted if conditions of jobs --- .github/workflows/pypi.yml | 47 +++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index a76369e..88c4521 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -1,24 +1,35 @@ name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI on: - pull_request: - types: [closed] + pull_request_target: branches: - develop - - main + types: + - closed + push: + tags: + - 'v*.*.*' + workflow_dispatch: inputs: - job: - description: "Select job to run" - required: true - type: choice - options: - - Build-and-publish-to-Test-PyPI - - test-install - - publish-to-pypi + test: + description: "Run tests" + default: true + type: boolean + publish_to_pypi: + description: "Publish to PyPI" + default: false + type: boolean jobs: Build-and-publish-to-Test-PyPI: + if: | + (github.event_name == 'workflow_dispatch' && + github.event.inputs.test == 'true') || + (github.event_name == 'pull_request_target' && + github.event.pull_request.merged && + contains(github.event.pull_request.labels.*.name, 'release')) || + (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -32,7 +43,7 @@ jobs: repository_name: "scraibe" repository_url: "https://test.pypi.org/legacy/" - test-install: + Test-PyPi-install: name: Test Installation from TestPyPI needs: Build-and-publish-to-Test-PyPI runs-on: ubuntu-latest @@ -54,8 +65,18 @@ jobs: publish-to-pypi: name: Publish to PyPI - needs: test-install + needs: Test-PyPi-install runs-on: ubuntu-latest + if: | + always() && + (( needs.Build-and-publish-to-Test-PyPI.result != 'failure' && + needs.Test-PyPi-install.result != 'failure' ) && + ((github.event_name == 'workflow_dispatch' && + github.event.inputs.publish_to_pypi == 'true') || + (github.event_name == 'pull_request_target' && + github.event.pull_request.merged && + contains(github.event.pull_request.labels.*.name, 'release')) || + (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')))) steps: - name: Checkout Repository Tags uses: actions/checkout@v4