From 0af73856c4fbc4f6e42bf28601c468cd1d20c49a Mon Sep 17 00:00:00 2001 From: "Alec Thomson (S&A, Kensington WA)" Date: Thu, 11 Jul 2024 15:26:50 +0800 Subject: [PATCH 1/3] Add workflow --- .github/workflows/pypi.yml | 96 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 .github/workflows/pypi.yml diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml new file mode 100644 index 0000000..f5aced9 --- /dev/null +++ b/.github/workflows/pypi.yml @@ -0,0 +1,96 @@ +name: Publish Python 🐍 distribution 📦 to PyPI + +on: + push: + tags: + - "v*.*.*" + +jobs: + build: + name: Build distribution 📦 + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + 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/RMextract + 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@v2.1.1 + 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 }}' \ No newline at end of file From 8ad1888146560268a9e137ae4e8ca85e93df5761 Mon Sep 17 00:00:00 2001 From: "Alec Thomson (S&A, Kensington WA)" Date: Thu, 11 Jul 2024 15:28:15 +0800 Subject: [PATCH 2/3] Add full script --- .github/workflows/pypi.yml | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index f5aced9..0ec938e 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -1,5 +1,8 @@ -name: Publish Python 🐍 distribution 📦 to PyPI +name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI +# Following https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ + +# Modified - only runs on tag pushes on: push: tags: @@ -39,7 +42,7 @@ jobs: runs-on: ubuntu-latest environment: name: pypi - url: https://pypi.org/p/RMextract + url: https://pypi.org/p/RMextract permissions: id-token: write # IMPORTANT: mandatory for trusted publishing @@ -93,4 +96,28 @@ jobs: run: >- gh release upload '${{ github.ref_name }}' dist/** - --repo '${{ github.repository }}' \ No newline at end of file + --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/ + + 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 f9687bfda6fa9e245993b7e7492acbc4a3d913f6 Mon Sep 17 00:00:00 2001 From: "Alec Thomson (S&A, Kensington WA)" Date: Thu, 11 Jul 2024 15:30:58 +0800 Subject: [PATCH 3/3] Mods --- .github/workflows/pypi.yml | 125 +++++++++++++++++++------------------ 1 file changed, 65 insertions(+), 60 deletions(-) diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index 0ec938e..688ccae 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -55,69 +55,74 @@ jobs: - 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 + # Uncomment the following block to sign the distributions with Sigstore + # Disabling for now to allow manual release creation + # 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 + # 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@v2.1.1 - 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 }}' + # 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@v2.1.1 + # 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 + # Uncomment the following block to publish to TestPyPI + # requires test.pypi.org configuration on: + # https://test.pypi.org/manage/account/publishing/ + # publish-to-testpypi: + # name: Publish Python 🐍 distribution 📦 to TestPyPI + # needs: + # - build + # runs-on: ubuntu-latest - environment: - name: testpypi - url: https://test.pypi.org/p/ + # environment: + # name: testpypi + # url: https://test.pypi.org/p/ - 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