From bf17c91ff0506b0839f16d3dbd2c22d84ada0f2f Mon Sep 17 00:00:00 2001 From: Diego Rivera Date: Wed, 2 Dec 2026 19:21:25 +0000 Subject: [PATCH] ci: migrate GitHub Release publishing workflow to OSS Exit Gate Signed-off-by: Diego Rivera --- .github/workflows/release.yml | 77 +++++++++++++++++++++++++++-------- 1 file changed, 61 insertions(+), 16 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cdcab6ca..5a0f41f0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -42,18 +42,12 @@ jobs: needs: [build_alioth, build_bootloader] runs-on: ubuntu-26.04 permissions: - contents: write # Required to create/modify releases + contents: read + id-token: write steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - - name: Get tag message - id: tag_message - run: | - echo "msg<> "$GITHUB_OUTPUT" - git show -s --format=%b HEAD | head -n -2 \ - >> "$GITHUB_OUTPUT" - echo "EOF" >> "$GITHUB_OUTPUT" - name: Download all artifacts uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 with: @@ -72,13 +66,64 @@ jobs: -C $PWD/alioth-cli cli.entitlements \ -C $PWD/docs macos-signing.md xz alioth-*-*.tar - - name: Create Release + - name: Authenticate to Google Cloud (OSS Exit Gate WIF) + uses: google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3.0.0 + with: + workload_identity_provider: 'projects/305452601764/locations/global/workloadIdentityPools/builders/providers/github' + - name: Set up Cloud SDK + uses: google-github-actions/setup-gcloud@aa5489c8933f4cc7a4f7d45035b3b1440c9c10db # v3.0.1 + - name: Clean up stale releases from staging repo + run: | + set -euo pipefail + packages=$(gcloud artifacts packages list \ + --project="oss-exit-gate-prod" \ + --location="us" \ + --repository="alioth--githubreleases" \ + --format="value(name)" 2>/dev/null || true) + for pkg in ${packages}; do + gcloud artifacts packages delete "${pkg}" \ + --project="oss-exit-gate-prod" \ + --location="us" \ + --repository="alioth--githubreleases" \ + --quiet || true + done + - name: Stage release artifacts and trigger OSS Exit Gate env: - GH_TOKEN: '${{ secrets.GITHUB_TOKEN }}' - STEPS_TAG_MESSAGE_OUTPUTS_MSG: ${{ steps.tag_message.outputs.msg }} + RELEASE_TAG: ${{ github.ref_name }} + RUN_ID: ${{ github.run_id }} + RUN_ATTEMPT: ${{ github.run_attempt }} run: | - gh release create "${GITHUB_REF_NAME}" \ - --title "Release ${GITHUB_REF_NAME}" \ - --notes "${STEPS_TAG_MESSAGE_OUTPUTS_MSG}" \ - --draft \ - alioth-*-*.tar.xz + set -euo pipefail + STAGE_DIR="$(mktemp -d "${RUNNER_TEMP}/exit-gate-stage.XXXXXX")" + trap 'rm -rf "${STAGE_DIR}"' EXIT + cp alioth-*-*.tar.xz "${STAGE_DIR}/" + ls -la "${STAGE_DIR}" + PKG_VERSION="$(printf '%s' "${RELEASE_TAG#v}" | tr '[:upper:]/+' '[:lower:]--' | sed 's/^[^a-z0-9]*//; s/[^a-z0-9._-]/-/g; s/[^a-z0-9]*$//')" + PKG_VERSION="${PKG_VERSION:-0.0.0}" + gcloud artifacts generic upload \ + --project=oss-exit-gate-prod \ + --repository=alioth--githubreleases \ + --location=us \ + --package=alioth \ + --version="${PKG_VERSION}" \ + --source-directory="${STAGE_DIR}" + python3 - <<'PY' > manifest.json + import json, os + tag = os.environ['RELEASE_TAG'] + manifest = { + 'publish_all': True, + 'registry_config': { + 'github_releases': { + 'name': f'Release {tag}', + 'tag': tag, + 'is_latest': False, + 'is_draft': True, + 'is_prerelease': False, + } + } + } + print(json.dumps(manifest, indent=2)) + PY + unset CLOUDSDK_CORE_PROJECT + gcloud storage cp manifest.json \ + "gs://oss-exit-gate-prod-projects-bucket/alioth/githubreleases/manifests/manifest-${RUN_ID}-${RUN_ATTEMPT}.json"