From 2ab8122b65f42883699352bf9aeccdc11b26858b Mon Sep 17 00:00:00 2001 From: "Pierre R. Mai" Date: Wed, 3 Apr 2024 14:10:04 +0200 Subject: [PATCH 1/2] Add initial TestPyPI package publishing Signed-off-by: Pierre R. Mai --- .github/workflows/protobuf.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/protobuf.yml b/.github/workflows/protobuf.yml index 40923dd62..501fb8ac3 100644 --- a/.github/workflows/protobuf.yml +++ b/.github/workflows/protobuf.yml @@ -26,6 +26,9 @@ jobs: runs-on: ubuntu-22.04 + permissions: + id-token: write + steps: - name: Checkout OSI uses: actions/checkout@v4 @@ -137,6 +140,11 @@ jobs: name: python-dist path: dist/ + - name: Publish Snapshot Release on TestPyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ + - name: Deploy to gh-pages if push to master branch if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} uses: peaceiris/actions-gh-pages@v3 From e9385ac7d55569ad0e7ba34942b4e74d35a97ba8 Mon Sep 17 00:00:00 2001 From: "Pierre R. Mai" Date: Fri, 5 Apr 2024 22:18:46 +0200 Subject: [PATCH 2/2] Split python publishing into separate job Signed-off-by: Pierre R. Mai --- .github/workflows/protobuf.yml | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/.github/workflows/protobuf.yml b/.github/workflows/protobuf.yml index 501fb8ac3..0a6401455 100644 --- a/.github/workflows/protobuf.yml +++ b/.github/workflows/protobuf.yml @@ -26,9 +26,6 @@ jobs: runs-on: ubuntu-22.04 - permissions: - id-token: write - steps: - name: Checkout OSI uses: actions/checkout@v4 @@ -134,17 +131,12 @@ jobs: if-no-files-found: error - name: Upload Python Distribution - if: ${{ github.event_name == 'pull_request' }} + if: ${{ github.event_name == 'pull_request' || ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) }} uses: actions/upload-artifact@v4 with: name: python-dist path: dist/ - - name: Publish Snapshot Release on TestPyPI - uses: pypa/gh-action-pypi-publish@release/v1 - with: - repository-url: https://test.pypi.org/legacy/ - - name: Deploy to gh-pages if push to master branch if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} uses: peaceiris/actions-gh-pages@v3 @@ -232,3 +224,27 @@ jobs: - name: Run Python Tests run: python -m unittest discover tests + + publish-python-dist: + name: Publish Python Distribution + + runs-on: ubuntu-22.04 + + permissions: + id-token: write + + needs: [build-proto2-linux64, build-proto3-linux64] + + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} + + steps: + - name: Download Distribution + uses: actions/download-artifact@v4 + with: + name: python-dist + path: dist/ + + - name: Publish Snapshot Release on TestPyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/