|
| 1 | +name: Release Please |
| 2 | + |
| 3 | +# `next` accumulates validated SDK changes in one versioned PR to `main`. |
| 4 | +# Merging that PR creates the GitHub release; the package publishing workflow |
| 5 | +# runs from the release event. |
| 6 | +on: |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - next |
| 10 | + - main |
| 11 | + |
| 12 | +permissions: |
| 13 | + contents: read |
| 14 | + |
| 15 | +concurrency: |
| 16 | + group: release-please |
| 17 | + cancel-in-progress: false |
| 18 | + |
| 19 | +jobs: |
| 20 | + release-please: |
| 21 | + if: github.repository == 'kernel/hypeman-python' |
| 22 | + runs-on: ubuntu-latest |
| 23 | + |
| 24 | + steps: |
| 25 | + - name: Mint release token |
| 26 | + id: release-token |
| 27 | + uses: actions/create-github-app-token@d72941d797fd3113feb6b93fd0dec494b13a2547 # v1 |
| 28 | + with: |
| 29 | + app-id: ${{ secrets.ADMIN_APP_ID }} |
| 30 | + private-key: ${{ secrets.ADMIN_APP_PRIVATE_KEY }} |
| 31 | + owner: kernel |
| 32 | + repositories: hypeman-python |
| 33 | + permission-contents: write |
| 34 | + permission-issues: write |
| 35 | + permission-pull-requests: write |
| 36 | + permission-workflows: write |
| 37 | + |
| 38 | + - name: Set up Node |
| 39 | + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 |
| 40 | + with: |
| 41 | + node-version: '18.20.2' |
| 42 | + |
| 43 | + - name: Set up pnpm |
| 44 | + uses: pnpm/action-setup@f40ffcd9367d9f12939873eb1018b921a783ffaa # v4 |
| 45 | + with: |
| 46 | + version: '9.11.0' |
| 47 | + run_install: false |
| 48 | + |
| 49 | + - name: Build pinned release tooling |
| 50 | + id: tooling |
| 51 | + env: |
| 52 | + RELEASE_PLEASE_DIR: ${{ runner.temp }}/release-please |
| 53 | + RELEASE_PLEASE_SHA: a116e1e520e0f87824acf46a2e79c91d41e819d7 |
| 54 | + run: | |
| 55 | + set -euo pipefail |
| 56 | + rm -rf "$RELEASE_PLEASE_DIR" |
| 57 | + git init "$RELEASE_PLEASE_DIR" |
| 58 | + git -C "$RELEASE_PLEASE_DIR" remote add origin https://github.com/stainless-api/release-please.git |
| 59 | + git -C "$RELEASE_PLEASE_DIR" fetch --depth=1 origin "$RELEASE_PLEASE_SHA" |
| 60 | + git -C "$RELEASE_PLEASE_DIR" checkout --detach FETCH_HEAD |
| 61 | + pnpm --dir "$RELEASE_PLEASE_DIR" install --frozen-lockfile |
| 62 | + pnpm --dir "$RELEASE_PLEASE_DIR" build |
| 63 | + echo "cli=$RELEASE_PLEASE_DIR/build/src/bin/release-please.js" >> "$GITHUB_OUTPUT" |
| 64 | +
|
| 65 | + - name: Open or update the release PR |
| 66 | + if: github.ref_name == 'next' |
| 67 | + env: |
| 68 | + GH_TOKEN: ${{ steps.release-token.outputs.token }} |
| 69 | + RELEASE_PLEASE: ${{ steps.tooling.outputs.cli }} |
| 70 | + run: | |
| 71 | + set -euo pipefail |
| 72 | + node "$RELEASE_PLEASE" release-pr \ |
| 73 | + --repo-url "$GITHUB_REPOSITORY" \ |
| 74 | + --token "$GH_TOKEN" \ |
| 75 | + --target-branch main \ |
| 76 | + --changes-branch next |
| 77 | +
|
| 78 | + - name: Remove the legacy promotion PR |
| 79 | + if: github.ref_name == 'next' |
| 80 | + env: |
| 81 | + GH_TOKEN: ${{ steps.release-token.outputs.token }} |
| 82 | + run: | |
| 83 | + set -euo pipefail |
| 84 | + legacy=$(gh pr list --repo "$GITHUB_REPOSITORY" --head stainless/release \ |
| 85 | + --state open --json number --jq '.[].number') |
| 86 | + for pr in $legacy; do |
| 87 | + gh pr close "$pr" --repo "$GITHUB_REPOSITORY" \ |
| 88 | + --comment "Superseded by the versioned release PR from next to main." |
| 89 | + done |
| 90 | + gh api -X DELETE "repos/$GITHUB_REPOSITORY/git/refs/heads/stainless/release" >/dev/null 2>&1 || true |
| 91 | +
|
| 92 | + - name: Create the GitHub release |
| 93 | + if: github.ref_name == 'main' |
| 94 | + env: |
| 95 | + GH_TOKEN: ${{ steps.release-token.outputs.token }} |
| 96 | + RELEASE_PLEASE: ${{ steps.tooling.outputs.cli }} |
| 97 | + run: | |
| 98 | + set -euo pipefail |
| 99 | + node "$RELEASE_PLEASE" github-release \ |
| 100 | + --repo-url "$GITHUB_REPOSITORY" \ |
| 101 | + --token "$GH_TOKEN" \ |
| 102 | + --target-branch main |
0 commit comments