From 0bf8d296547a8d1da09177dc283e2e99c1679b87 Mon Sep 17 00:00:00 2001 From: Jadson Ribeiro Date: Thu, 28 Dec 2023 18:11:11 +0000 Subject: [PATCH 1/5] Added action publish pypi --- .github/workflows/publish_pypi.yml | 123 +++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 .github/workflows/publish_pypi.yml diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml new file mode 100644 index 0000000..c325707 --- /dev/null +++ b/.github/workflows/publish_pypi.yml @@ -0,0 +1,123 @@ +name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI + +# on: push +on: + push: + branches: + - action-publish-pypi + # - master + # - develop + +jobs: + build: + name: Build distribution 📦 + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.x" + - name: Install pypa/build + run: >- + python3 -m + pip install + build + --user + - name: Build a binary wheel and a source tarball + run: python3 -m build + - name: Store the distribution packages + uses: actions/upload-artifact@v3 + with: + name: python-package-distributions + path: dist/ + + publish-to-pypi: + name: >- + Publish Python 🐍 distribution 📦 to PyPI + if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes + needs: + - build + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/pyreportjasper + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing + + steps: + - name: Download all the dists + uses: actions/download-artifact@v3 + with: + name: python-package-distributions + path: dist/ + - name: Publish distribution 📦 to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + + github-release: + name: >- + Sign the Python 🐍 distribution 📦 with Sigstore + and upload them to GitHub Release + needs: + - publish-to-pypi + runs-on: ubuntu-latest + + permissions: + contents: write # IMPORTANT: mandatory for making GitHub Releases + id-token: write # IMPORTANT: mandatory for sigstore + + steps: + - name: Download all the dists + uses: actions/download-artifact@v3 + with: + name: python-package-distributions + path: dist/ + - name: Sign the dists with Sigstore + uses: sigstore/gh-action-sigstore-python@v1.2.3 + with: + inputs: >- + ./dist/*.tar.gz + ./dist/*.whl + - name: Create GitHub Release + env: + GITHUB_TOKEN: ${{ github.token }} + run: >- + gh release create + '${{ github.ref_name }}' + --repo '${{ github.repository }}' + --notes "" + - name: Upload artifact signatures to GitHub Release + env: + GITHUB_TOKEN: ${{ github.token }} + # Upload to GitHub Release using the `gh` CLI. + # `dist/` contains the built packages, and the + # sigstore-produced signatures and certificates. + run: >- + gh release upload + '${{ github.ref_name }}' dist/** + --repo '${{ github.repository }}' + + publish-to-testpypi: + name: Publish Python 🐍 distribution 📦 to TestPyPI + needs: + - build + runs-on: ubuntu-latest + + environment: + name: testpypi + url: https://test.pypi.org/p/pyreportjasper + + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing + + steps: + - name: Download all the dists + uses: actions/download-artifact@v3 + with: + name: python-package-distributions + path: dist/ + - name: Publish distribution 📦 to TestPyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ \ No newline at end of file From 4a7c9bebbb662ea9b60997c2edfa762298309367 Mon Sep 17 00:00:00 2001 From: Jadson Ribeiro Date: Thu, 28 Dec 2023 18:14:43 +0000 Subject: [PATCH 2/5] Commented publish-to-testpypi --- .github/workflows/publish_pypi.yml | 40 +++++++++++++++--------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index c325707..fc84dcd 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -98,26 +98,26 @@ jobs: '${{ github.ref_name }}' dist/** --repo '${{ github.repository }}' - publish-to-testpypi: - name: Publish Python 🐍 distribution 📦 to TestPyPI - needs: - - build - runs-on: ubuntu-latest + # publish-to-testpypi: + # name: Publish Python 🐍 distribution 📦 to TestPyPI + # needs: + # - build + # runs-on: ubuntu-latest - environment: - name: testpypi - url: https://test.pypi.org/p/pyreportjasper + # environment: + # name: testpypi + # url: https://test.pypi.org/p/pyreportjasper - permissions: - id-token: write # IMPORTANT: mandatory for trusted publishing + # permissions: + # id-token: write # IMPORTANT: mandatory for trusted publishing - steps: - - name: Download all the dists - uses: actions/download-artifact@v3 - with: - name: python-package-distributions - path: dist/ - - name: Publish distribution 📦 to TestPyPI - uses: pypa/gh-action-pypi-publish@release/v1 - with: - repository-url: https://test.pypi.org/legacy/ \ No newline at end of file + # steps: + # - name: Download all the dists + # uses: actions/download-artifact@v3 + # with: + # name: python-package-distributions + # path: dist/ + # - name: Publish distribution 📦 to TestPyPI + # uses: pypa/gh-action-pypi-publish@release/v1 + # with: + # repository-url: https://test.pypi.org/legacy/ \ No newline at end of file From ba48b3c344d37af61cc651bde815a8315a7c7349 Mon Sep 17 00:00:00 2001 From: Jadson Ribeiro Date: Thu, 28 Dec 2023 18:47:20 +0000 Subject: [PATCH 3/5] Adjustments publish pypi --- .github/workflows/publish_pypi.yml | 32 ++---------------------------- 1 file changed, 2 insertions(+), 30 deletions(-) diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index fc84dcd..c8bc438 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -1,12 +1,8 @@ name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI -# on: push on: - push: - branches: - - action-publish-pypi - # - master - # - develop + release: + types: [published, edited] jobs: build: @@ -97,27 +93,3 @@ jobs: gh release upload '${{ github.ref_name }}' dist/** --repo '${{ github.repository }}' - - # publish-to-testpypi: - # name: Publish Python 🐍 distribution 📦 to TestPyPI - # needs: - # - build - # runs-on: ubuntu-latest - - # environment: - # name: testpypi - # url: https://test.pypi.org/p/pyreportjasper - - # permissions: - # id-token: write # IMPORTANT: mandatory for trusted publishing - - # steps: - # - name: Download all the dists - # uses: actions/download-artifact@v3 - # with: - # name: python-package-distributions - # path: dist/ - # - name: Publish distribution 📦 to TestPyPI - # uses: pypa/gh-action-pypi-publish@release/v1 - # with: - # repository-url: https://test.pypi.org/legacy/ \ No newline at end of file From 35b2d7633844812aa5e365494d81ce963062c420 Mon Sep 17 00:00:00 2001 From: Jadson Ribeiro Date: Thu, 28 Dec 2023 18:49:19 +0000 Subject: [PATCH 4/5] Adjustments publish pypi --- .github/workflows/publish_pypi.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index c8bc438..e5de4a4 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -1,4 +1,4 @@ -name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI +name: Publish Python 🐍 distribution 📦 to PyPI on: release: From 8a103f21d0c0a7a9038f0f1943b95d3afbd577a4 Mon Sep 17 00:00:00 2001 From: Jadson Ribeiro Date: Thu, 28 Dec 2023 18:53:07 +0000 Subject: [PATCH 5/5] Adjustments upload pypi --- .github/workflows/publish_pypi.yml | 102 ++++++----------------------- 1 file changed, 19 insertions(+), 83 deletions(-) diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index e5de4a4..9d0e9e9 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -1,95 +1,31 @@ -name: Publish Python 🐍 distribution 📦 to PyPI +name: Upload Python Package on: release: types: [published, edited] -jobs: - build: - name: Build distribution 📦 - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: "3.x" - - name: Install pypa/build - run: >- - python3 -m - pip install - build - --user - - name: Build a binary wheel and a source tarball - run: python3 -m build - - name: Store the distribution packages - uses: actions/upload-artifact@v3 - with: - name: python-package-distributions - path: dist/ +permissions: + contents: read - publish-to-pypi: - name: >- - Publish Python 🐍 distribution 📦 to PyPI - if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes - needs: - - build - runs-on: ubuntu-latest - environment: - name: pypi - url: https://pypi.org/p/pyreportjasper - permissions: - id-token: write # IMPORTANT: mandatory for trusted publishing - - steps: - - name: Download all the dists - uses: actions/download-artifact@v3 - with: - name: python-package-distributions - path: dist/ - - name: Publish distribution 📦 to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 +jobs: + deploy: - github-release: - name: >- - Sign the Python 🐍 distribution 📦 with Sigstore - and upload them to GitHub Release - needs: - - publish-to-pypi runs-on: ubuntu-latest - permissions: - contents: write # IMPORTANT: mandatory for making GitHub Releases - id-token: write # IMPORTANT: mandatory for sigstore - steps: - - name: Download all the dists - uses: actions/download-artifact@v3 + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v3 with: - name: python-package-distributions - path: dist/ - - name: Sign the dists with Sigstore - uses: sigstore/gh-action-sigstore-python@v1.2.3 + python-version: '3.x' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build + - name: Build package + run: python -m build + - name: Publish package + uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 with: - inputs: >- - ./dist/*.tar.gz - ./dist/*.whl - - name: Create GitHub Release - env: - GITHUB_TOKEN: ${{ github.token }} - run: >- - gh release create - '${{ github.ref_name }}' - --repo '${{ github.repository }}' - --notes "" - - name: Upload artifact signatures to GitHub Release - env: - GITHUB_TOKEN: ${{ github.token }} - # Upload to GitHub Release using the `gh` CLI. - # `dist/` contains the built packages, and the - # sigstore-produced signatures and certificates. - run: >- - gh release upload - '${{ github.ref_name }}' dist/** - --repo '${{ github.repository }}' + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }}