diff --git a/.github/workflows/build-dist.yml b/.github/workflows/build-dist.yml index 1e05102..2dd201d 100644 --- a/.github/workflows/build-dist.yml +++ b/.github/workflows/build-dist.yml @@ -1,61 +1,121 @@ -name: Build and upload to PyPI +name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI +# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ -# Build on every branch push, tag push, and pull request change: on: [push, pull_request, workflow_dispatch] -# Alternatively, to publish when a (published) GitHub Release is created, use the following: -# on: -# push: -# pull_request: -# release: -# types: -# - published jobs: - build_sdist: - name: Build source distribution - runs-on: ubuntu-22.04 + build: + name: Build distribution 📦 + runs-on: ubuntu-latest + steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - submodules: true + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + submodules: true + - 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/ - - name: Build SDist - run: pipx run build --sdist +# 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/roseus +# 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 - - name: Check metadata - run: pipx run twine check dist/* + permissions: + contents: write # IMPORTANT: mandatory for making GitHub Releases + id-token: write # IMPORTANT: mandatory for sigstore - - uses: actions/upload-artifact@v4 - with: - name: sdist - path: dist/*.tar.gz + 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 }}' - upload_pypi: - needs: [build_sdist] + publish-to-testpypi: + name: Publish Python 🐍 distribution 📦 to TestPyPI + needs: + - build runs-on: ubuntu-latest - # upload to PyPI on every tag starting with 'v' - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') - # alternatively, to publish when a GitHub Release is created, use the following rule: - # if: github.event_name == 'release' && github.event.action == 'published' + + environment: + name: testpypi + url: https://test.pypi.org/p/roseus + + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing + steps: - - uses: actions/download-artifact@v4 - with: - path: dist - pattern: "*" - merge-multiple: true - - - uses: softprops/action-gh-release@v2 - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') - with: - files: | - dist/*.tar.gz - dist/*.whl - - - uses: pypa/gh-action-pypi-publish@release/v1 - with: - user: __token__ - password: ${{ secrets.PYPI_API_TOKEN }} - # To test - # password: ${{ secrets.TEST_PYPI_API_TOKEN }} - # repository_url: https://test.pypi.org/legacy/ + - 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/ diff --git a/pyproject.toml b/pyproject.toml index e125030..8edde5d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,9 +30,6 @@ generate = ["colour-science", "matplotlib", "numpy", "colorspacious", "scipy"] Homepage = "https://github.com/dofuuz/roseus" Source = "https://github.com/dofuuz/roseus" -[tool.setuptools] -packages = ["roseus"] - [tool.cibuildwheel] # Necessary to see build output from the actual compilation build-verbosity = 1