diff --git a/.github/workflows/pypi-ci.yml b/.github/workflows/pypi-ci.yml index 95f227fd..8042ad88 100644 --- a/.github/workflows/pypi-ci.yml +++ b/.github/workflows/pypi-ci.yml @@ -3,14 +3,11 @@ name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI # Ref: https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ on: - workflow_dispatch: - push: - branches: ["**"] - tags-ignore: ["**"] - pull_request: release: - types: - - published + types: [published] + pull_request: + workflow_dispatch: + jobs: build: name: Build distribution 📦 @@ -18,10 +15,13 @@ jobs: steps: - uses: actions/checkout@v4 + with: + persist-credentials: false + fetch-depth: 0 - name: Set up Python uses: actions/setup-python@v5 with: - python-version: "3.8" + python-version: "3.x" - name: Install pypa/build run: >- python3 -m @@ -33,19 +33,19 @@ jobs: - name: Store the distribution packages uses: actions/upload-artifact@v4 with: - name: python-package-distributions - path: dist/ + name: dist + path: dist publish-to-pypi: - name: >- - Publish Python 🐍 distribution 📦 to PyPI + name: Publish Python 🐍 distribution 📦 to PyPI + needs: build if: github.event_name == 'release' || startsWith(github.ref, 'refs/tags/') - needs: - - build runs-on: ubuntu-latest + environment: name: pypi url: https://pypi.org/p/adam-robotics + permissions: id-token: write # IMPORTANT: mandatory for trusted publishing @@ -53,59 +53,16 @@ jobs: - name: Download all the dists uses: actions/download-artifact@v4 with: - name: python-package-distributions - path: dist/ + name: dist + 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@v4 - with: - name: python-package-distributions - path: dist/ - - name: Sign the dists with Sigstore - uses: sigstore/gh-action-sigstore-python@v3.0.0 - 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 - if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/') - needs: - - build + needs: build + if: github.event_name == 'workflow_dispatch' runs-on: ubuntu-latest environment: @@ -119,9 +76,11 @@ jobs: - name: Download all the dists uses: actions/download-artifact@v4 with: - name: python-package-distributions - path: dist/ + name: dist + path: dist - name: Publish distribution 📦 to TestPyPI uses: pypa/gh-action-pypi-publish@release/v1 with: repository-url: https://test.pypi.org/legacy/ + verbose: true + skip-existing: true diff --git a/pyproject.toml b/pyproject.toml index fe8f4c25..3581c6eb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [build-system] +requires = ["setuptools>=64", "setuptools_scm>=8", "wheel"] build-backend = "setuptools.build_meta" -requires = ["wheel", "setuptools>=45", "setuptools_scm[toml]>=6.0"] [project] name = "adam-robotics" @@ -57,6 +57,9 @@ all = ["jax", "jaxlib", "casadi>=3.6", "torch", "jax2torch"] "Documentation" = "https://adam-robotics.readthedocs.io/en/latest/" "Source" = "https://github.com/ami-iit/adam" +[tool.setuptools_scm] +local_scheme = "dirty-tag" + [tool.setuptools] package-dir = { "" = "src" } # keeps the src/ layout