diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..aa1aada --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,82 @@ +name: CD + +on: + merge_group: + push: + branches: + - main + tags: + - '*' + release: + types: [published] + +permissions: + contents: read + +jobs: + packaging: + if: github.repository_owner == 'sgkit-dev' + name: Packaging + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + fetch-depth: 0 + persist-credentials: false + + - name: Install uv and set the python version + uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0 + with: + python-version: "3.12" + enable-cache: false + + - name: Build artefacts + run: uv build + + - name: Store the distribution packages + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: python-package-distributions + path: dist/ + + publish-to-pypi: + if: github.repository_owner == 'sgkit-dev' && github.event_name == 'release' + needs: + - packaging + runs-on: ubuntu-latest + + environment: + name: pypi + url: https://pypi.org/p/vczstore + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing + + steps: + - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: python-package-distributions + path: dist/ + - uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # release/v1 + + + publish-to-testpypi: + if: github.repository_owner == 'sgkit-dev' && github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') + needs: + - packaging + runs-on: ubuntu-latest + + environment: + name: testpypi + url: https://test.pypi.org/p/vczstore + + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing + + steps: + - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: python-package-distributions + path: dist/ + - uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # release/v1 + with: + repository-url: https://test.pypi.org/legacy/