From b933507c359a17b635666e17e6b1b643a7630273 Mon Sep 17 00:00:00 2001 From: DanielePalaia Date: Mon, 20 Jan 2025 13:48:48 +0100 Subject: [PATCH 1/2] adding an action to publish on pypi on a new release --- .github/workflows/publish-pypi.yaml | 41 ++++++++++++++++++++++++++ .github/workflows/publish_release.yaml | 17 +++++++++++ 2 files changed, 58 insertions(+) create mode 100644 .github/workflows/publish-pypi.yaml create mode 100644 .github/workflows/publish_release.yaml diff --git a/.github/workflows/publish-pypi.yaml b/.github/workflows/publish-pypi.yaml new file mode 100644 index 0000000..9eeb4cb --- /dev/null +++ b/.github/workflows/publish-pypi.yaml @@ -0,0 +1,41 @@ +name: publish-pypi + +on: + workflow_call: + inputs: + pypi_repository_url: + required: true + type: string + secrets: + pypi_api_login: + required: true + pypi_api_password: + required: true + +jobs: + pypi-publish: + name: upload release to PyPI + runs-on: ubuntu-latest + # Specifying a GitHub environment is optional, but strongly encouraged + environment: + name: pypi + url: https://pypi.org/p/rabbitmq-amqp-python-client + permissions: + # IMPORTANT: this permission is mandatory for trusted publishing + id-token: write + steps: + - uses: actions/checkout@v3 + - name: build with poetry + env: + REPO: ${{ inputs.pypi_repository_url }} + run: | + curl -sSL https://install.python-poetry.org | python3 - + export PATH="/home/runner/.local/bin:$PATH" + poetry config repositories.test-pypi $REPO + poetry build + # retrieve your distributions here + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + verbose: true + attestations: false diff --git a/.github/workflows/publish_release.yaml b/.github/workflows/publish_release.yaml new file mode 100644 index 0000000..04c6bc0 --- /dev/null +++ b/.github/workflows/publish_release.yaml @@ -0,0 +1,17 @@ +name: publish-release + +on: + release: + types: + - released + +jobs: + call-publish-pypi: + permissions: + id-token: write + uses: ./.github/workflows/publish-pypi.yaml + with: + pypi_repository_url: https://upload.pypi.org/legacy/ + secrets: + pypi_api_login: __token__ + pypi_api_password: ${{ secrets.PYPI_TOKEN }} \ No newline at end of file From b8500c2ac5f730dc7d526d436e61a2b7b28cc0ca Mon Sep 17 00:00:00 2001 From: DanielePalaia Date: Mon, 20 Jan 2025 16:14:17 +0100 Subject: [PATCH 2/2] running test action on main --- .github/workflows/build-test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-test.yaml b/.github/workflows/build-test.yaml index d4c98e4..af2ab1a 100644 --- a/.github/workflows/build-test.yaml +++ b/.github/workflows/build-test.yaml @@ -3,7 +3,7 @@ name: Test against a RabbitMQ broker on: push: branches: - - master + - main pull_request: types: - opened