From 5ad9bec3888cbfc9b9d9eb3ef1a382686237a848 Mon Sep 17 00:00:00 2001 From: Markus Bilz Date: Mon, 4 Dec 2023 21:27:41 +0100 Subject: [PATCH 1/5] Add 'skip-existing' back in --- .github/workflows/publish.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 4ede1fa..2b8d5c7 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -36,6 +36,7 @@ jobs: with: password: ${{secrets.TEST_PYPI_API_TOKEN}} repository-url: https://test.pypi.org/legacy/ + skip-existing: true - name: Publish distribution 📦 to PyPI if: startsWith(github.ref, 'refs/tags') uses: pypa/gh-action-pypi-publish@release/v1 From 4e179aaf84e284e8b6d51d60ad9fe2ce5aaf9831 Mon Sep 17 00:00:00 2001 From: Markus Bilz Date: Mon, 11 Dec 2023 14:14:47 +0100 Subject: [PATCH 2/5] Extend 'publish.yaml' --- .github/workflows/publish.yaml | 147 ++++++++++++++++++++++++--------- 1 file changed, 110 insertions(+), 37 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 2b8d5c7..429a983 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -1,44 +1,117 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. +# adapted from here: https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ -# GitHub recommends pinning actions to a commit SHA. -# To get a newer version, you will need to update the SHA. -# You can also reference a tag or branch, but the action may change without warning. +on: push -name: Upload Python Package +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/ -on: - release: - types: [published] + publish-to-pypi: + name: >- + Publish Python 🐍 distribution 📦 to PyPI + if: startsWith(github.ref, 'refs/tags/') + needs: + - build + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/tclf + permissions: + id-token: write - # Enable manual run - workflow_dispatch: + 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 + id-token: write + + 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/ + + permissions: + id-token: write + steps: - - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.12' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install build - - name: Build package - run: python -m build - - name: Publish distribution 📦 to Test PyPI - uses: pypa/gh-action-pypi-publish@release/v1 - with: - password: ${{secrets.TEST_PYPI_API_TOKEN}} - repository-url: https://test.pypi.org/legacy/ - skip-existing: true - - name: Publish distribution 📦 to PyPI - if: startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@release/v1 - with: - password: ${{ secrets.PYPI_API_TOKEN }} + - 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/ From daaac771d4288309aa994b06e56672bc90b951f5 Mon Sep 17 00:00:00 2001 From: Markus Bilz Date: Mon, 11 Dec 2023 14:42:56 +0100 Subject: [PATCH 3/5] =?UTF-8?q?Improve=20gh=20actions=20=F0=9F=90=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/{.dependabot.yaml => dependabot.yaml} | 0 .github/workflows/publish.yaml | 6 +++--- pyproject.toml | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) rename .github/{.dependabot.yaml => dependabot.yaml} (100%) diff --git a/.github/.dependabot.yaml b/.github/dependabot.yaml similarity index 100% rename from .github/.dependabot.yaml rename to .github/dependabot.yaml diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 429a983..2fd2586 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -15,12 +15,12 @@ jobs: python-version: "3.x" - name: Install pypa/build run: >- - python3 -m + python -m pip install build --user - name: Build a binary wheel and a source tarball - run: python3 -m build + run: python -m build - name: Store the distribution packages uses: actions/upload-artifact@v3 with: @@ -100,7 +100,7 @@ jobs: environment: name: testpypi - url: https://test.pypi.org/p/ + url: https://test.pypi.org/p/tclf permissions: id-token: write diff --git a/pyproject.toml b/pyproject.toml index 371acbb..61f4628 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,6 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "tclf" +version = "0.0.1" authors = [ { name="Markus Bilz", email="github@markusbilz.com" }, ] From 4133ab8cf08a15d59291ea74dc4c1263ac345a2d Mon Sep 17 00:00:00 2001 From: Markus Bilz Date: Mon, 11 Dec 2023 14:47:48 +0100 Subject: [PATCH 4/5] Add manual version to pyproject.toml --- pyproject.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 61f4628..49b2f72 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,8 +33,6 @@ dependencies = [ "scikit-learn" ] -dynamic = ["version"] - [project.urls] "Homepage" = "https://github.com/KarelZe/tclf" "Bug Tracker" = "https://github.com/KarelZe/tclf/issues" From 0f3e6c6dbd80c4842600b21236c506bd489cdb89 Mon Sep 17 00:00:00 2001 From: Markus Bilz Date: Mon, 11 Dec 2023 15:00:27 +0100 Subject: [PATCH 5/5] Add 'skip-existing' option back in --- .github/workflows/publish.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 2fd2586..9ded369 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -114,4 +114,5 @@ jobs: - name: Publish distribution 📦 to TestPyPI uses: pypa/gh-action-pypi-publish@release/v1 with: + skip-existing: true repository-url: https://test.pypi.org/legacy/