|
| 1 | +name: Release Gate |
| 2 | +on: |
| 3 | + pull_request: |
| 4 | + types: [closed] |
| 5 | + branches: [main] |
| 6 | + paths: ['.releases/**'] |
| 7 | + |
| 8 | +concurrency: |
| 9 | + group: release-gate |
| 10 | + cancel-in-progress: false |
| 11 | + |
| 12 | +jobs: |
| 13 | + create-release-tag: |
| 14 | + name: Create tag and dispatch release |
| 15 | + runs-on: ubuntu-latest |
| 16 | + timeout-minutes: 5 |
| 17 | + if: github.event.pull_request.merged == true |
| 18 | + permissions: |
| 19 | + contents: write |
| 20 | + actions: write |
| 21 | + steps: |
| 22 | + - name: Fail if App credentials are not configured |
| 23 | + run: | |
| 24 | + if [ -z "${{ secrets.APP_ID }}" ] || [ -z "${{ secrets.APP_PRIVATE_KEY }}" ]; then |
| 25 | + echo "❌ APP_ID and APP_PRIVATE_KEY must be configured." |
| 26 | + echo "For fork testing, install a personal GitHub App on the fork," |
| 27 | + echo "create a private key, and add both as repository secrets." |
| 28 | + exit 1 |
| 29 | + fi |
| 30 | +
|
| 31 | + - uses: actions/checkout@v6 |
| 32 | + with: |
| 33 | + fetch-depth: 0 |
| 34 | + |
| 35 | + - uses: actions/create-github-app-token@v3 |
| 36 | + id: app-token |
| 37 | + with: |
| 38 | + app-id: ${{ secrets.APP_ID }} |
| 39 | + private-key: ${{ secrets.APP_PRIVATE_KEY }} |
| 40 | + |
| 41 | + - uses: actions/setup-python@v6 |
| 42 | + with: |
| 43 | + python-version: '3.x' |
| 44 | + |
| 45 | + - name: Install Python deps |
| 46 | + run: pip install pyyaml |
| 47 | + |
| 48 | + - name: Create tag from release request |
| 49 | + id: gate |
| 50 | + env: |
| 51 | + GH_TOKEN: ${{ steps.app-token.outputs.token }} |
| 52 | + REPO: ${{ github.repository }} |
| 53 | + BASE_SHA: ${{ github.event.pull_request.base.sha }} |
| 54 | + MERGE_SHA: ${{ github.event.pull_request.merge_commit_sha }} |
| 55 | + run: | |
| 56 | + python .github/workflows/release/release.py gate | tee /tmp/gate-output.txt |
| 57 | + TAG=$(grep '^tag=' /tmp/gate-output.txt | tail -1 | cut -d= -f2-) |
| 58 | + COMMIT=$(grep '^commit=' /tmp/gate-output.txt | tail -1 | cut -d= -f2-) |
| 59 | + echo "tag=$TAG" >> $GITHUB_OUTPUT |
| 60 | + echo "commit=$COMMIT" >> $GITHUB_OUTPUT |
| 61 | +
|
| 62 | + if [ -z "$TAG" ] || [ -z "$COMMIT" ]; then |
| 63 | + echo "❌ gate did not emit tag= / commit= outputs" |
| 64 | + exit 1 |
| 65 | + fi |
| 66 | + echo "Gate outputs: $TAG @ $COMMIT" |
| 67 | +
|
| 68 | + - name: Dispatch release workflow |
| 69 | + env: |
| 70 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 71 | + run: | |
| 72 | + gh workflow run release.yml \ |
| 73 | + --ref main \ |
| 74 | + -f tag=${{ steps.gate.outputs.tag }} |
0 commit comments