diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fc0b3505..1d01c612 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -225,6 +225,7 @@ jobs: timeout-minutes: 30 runs-on: ubuntu-latest permissions: + contents: read id-token: write attestations: write # Requires environment protection rules in GitHub Settings: @@ -241,5 +242,21 @@ jobs: - uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2 with: subject-path: "dist/*" - # To upload to PyPI without a token, add this workflow file as a Trusted Publisher in the project settings on the PyPI website - - uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2 + - name: Authenticate to OSS Exit Gate + uses: google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3.0.0 + with: + workload_identity_provider: 'projects/305452601764/locations/global/workloadIdentityPools/builders/providers/github' + - name: Stage package in OSS Exit Gate Artifact Registry + run: | + python3 -m venv .exit-gate-venv + .exit-gate-venv/bin/pip install --upgrade pip keyring twine keyrings.google-artifactregistry-auth + .exit-gate-venv/bin/twine upload \ + --repository-url https://us-python.pkg.dev/oss-exit-gate-prod/s2geometry--pypi \ + dist/* + - name: Trigger OSS Exit Gate release + run: | + MANIFEST_FILE="$(mktemp)" + echo '{"publish_all": true}' > "${MANIFEST_FILE}" + gcloud storage cp "${MANIFEST_FILE}" \ + "gs://oss-exit-gate-prod-projects-bucket/s2geometry/pypi/manifests/manifest-${{ github.run_id }}-${{ github.run_attempt }}.json" + rm -f "${MANIFEST_FILE}"