From 9e22ef4ee15e7b393821501d4283ce1d138e52c1 Mon Sep 17 00:00:00 2001 From: Joel Greer Date: Mon, 4 Dec 2023 23:59:14 +0000 Subject: [PATCH] Workflow for pypi auto-publishing --- .github/workflows/publish-to-pypi.yml | 114 ++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 .github/workflows/publish-to-pypi.yml diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml new file mode 100644 index 0000000..34d2558 --- /dev/null +++ b/.github/workflows/publish-to-pypi.yml @@ -0,0 +1,114 @@ +name: publish-roodmus-to-pypi + +on: push + +jobs: + build: + name: build-dist + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: setup-python + uses: actions/setup-python@v4 + with: + python-version: "3.10.4" + - name: install-pypa/build + run: >- + python3 -m + pip install + build + --user + - name: build-bin-whl + run: python3 -m build + - name: grab-build + uses: actions/upload-artifact@v3 + with: + name: pkg-dist + path: dist/ + + publish-to-pypi: + name: >- + publish-to-pypi + if: startsWith(github.ref, 'ref/tags/') + needs: + - build + runs-on: ubuntu-latest + environment: + name: production + url: https://pypi.org/p/roodmus + permissions: + -id-token: write + + steps: + - name: download-dists + uses: actions/download-artifact@v3 + with: + name: pkg-dist + path: dist/ + - name: publish-dist-to-pypi + uses: pypa/gh-action-pypi-publish@release/v1 + + github-release: + name: >- + sign-dist-via-sigstore-and-upload-to-github-release + needs: + - publish-to-pypi + runs-on: ubuntu-latest + + permissions: + contents: write + id-token: write + + steps: + - name: download-dists + uses: actions/download-artifact@v3 + with: + name: pkg-dist + path: dist/ + - name: sign-dists + 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-signature-to-github-release + env: + GITHUB_TOKEN: ${{ github.token }} + run: >- + gh release upload + '${{ github.ref_name }}' dist/** + --repo '${{ github.repository }}' + + publish-to-test-pypi: + name: publish-to-test-pypi + if: startsWith('ref/head/main', 'ref/head/development', 'ref/tags/') + needs: + - build + runs-on: ubuntu-latest + + environment: + name: testing + url: https://test.pypi/org/p/roodmus + + permissions: + id-token: write + + steps: + - name: download-dists + uses: actions/download-artifact@v3 + with: + name: pkg-dist + path: dist/ + - name: publish-dist-to-test-pypi + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/ \ No newline at end of file