From d45c0138061dfc48c7bed8364f69756b5e01fc5b Mon Sep 17 00:00:00 2001 From: Andy Lee Date: Thu, 24 Jul 2025 19:25:11 -0700 Subject: [PATCH] fix: handle workflow trigger permission gracefully --- .github/workflows/release-manual.yml | 51 +++++++++++++++++++++++++++- docs/RELEASE.md | 11 ++++++ 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release-manual.yml b/.github/workflows/release-manual.yml index 98b1ab8..d2da5ae 100644 --- a/.github/workflows/release-manual.yml +++ b/.github/workflows/release-manual.yml @@ -76,6 +76,16 @@ jobs: - name: Trigger CI build run: | echo "🚀 Manually triggering CI for the new version..." + + # Check if we have a PAT for triggering workflows + if [ -z "${{ secrets.WORKFLOW_PAT }}" ]; then + echo "⚠️ No WORKFLOW_PAT found. CI will be triggered by the push event." + echo " Note: If CI doesn't trigger automatically, you'll need to:" + echo " 1. Add a Personal Access Token with 'workflow' scope as WORKFLOW_PAT secret" + echo " 2. Or manually run the CI workflow after this release completes" + exit 0 + fi + gh workflow run "CI - Build Multi-Platform Packages" \ --ref main \ -f publish=false @@ -83,7 +93,7 @@ jobs: # Give GitHub a moment to register the new workflow run sleep 5 env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_TOKEN: ${{ secrets.WORKFLOW_PAT || secrets.GITHUB_TOKEN }} - name: Wait for CI to complete id: wait-for-ci @@ -91,6 +101,45 @@ jobs: echo "⏳ Waiting for CI to build new version..." COMMIT_SHA="${{ steps.push-version.outputs.commit-sha }}" + # First, wait a bit for CI to potentially start + echo "⏳ Waiting for CI to start..." + sleep 30 + + # Check if there's any CI run for this commit + CI_EXISTS=$(gh run list \ + --workflow="CI - Build Multi-Platform Packages" \ + --commit=$COMMIT_SHA \ + --json databaseId \ + --jq 'length') + + if [ "$CI_EXISTS" -eq "0" ]; then + echo "⚠️ No CI run found for commit $COMMIT_SHA" + echo " This might be because:" + echo " 1. WORKFLOW_PAT is not configured" + echo " 2. CI hasn't started yet" + echo "" + echo " You can manually trigger CI after this release completes:" + echo " gh workflow run 'CI - Build Multi-Platform Packages' --ref main" + echo "" + echo " For now, we'll use the artifacts from the latest successful CI run." + + # Get the latest successful CI run + LATEST_RUN=$(gh run list \ + --workflow="CI - Build Multi-Platform Packages" \ + --status=success \ + --json databaseId \ + --jq '.[0].databaseId') + + if [ -z "$LATEST_RUN" ]; then + echo "❌ No successful CI runs found!" + exit 1 + fi + + echo "📦 Using artifacts from CI run: $LATEST_RUN" + echo "run-id=$LATEST_RUN" >> $GITHUB_OUTPUT + exit 0 + fi + # Wait up to 20 minutes for CI to complete for i in {1..40}; do # First check if CI is running diff --git a/docs/RELEASE.md b/docs/RELEASE.md index 985a282..69da211 100644 --- a/docs/RELEASE.md +++ b/docs/RELEASE.md @@ -1,5 +1,16 @@ # Release Guide +## Required: PyPI Configuration + +Before releasing, ensure you have configured the PyPI API token: + +1. Generate API token at https://pypi.org/manage/account/token/ +2. Add as GitHub secret: `PYPI_API_TOKEN` +3. For full automation, also add a Personal Access Token: + - Create PAT at https://github.com/settings/tokens with `workflow` scope + - Add as GitHub secret: `WORKFLOW_PAT` + - This allows the release workflow to trigger CI builds automatically + ## 📋 Prerequisites Before releasing, ensure: