Merge pull request #4 from kernel/hypeship/single-sdk-release-pr #10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release Please | |
| # `next` accumulates validated SDK changes in one versioned PR to `main`. | |
| # Merging that PR creates the GitHub release; the package publishing workflow | |
| # runs from the release event. | |
| on: | |
| push: | |
| branches: | |
| - next | |
| - main | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: release-please | |
| cancel-in-progress: false | |
| jobs: | |
| release-please: | |
| if: github.repository == 'kernel/kernel-python-sdk' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Mint release token | |
| id: release-token | |
| uses: actions/create-github-app-token@d72941d797fd3113feb6b93fd0dec494b13a2547 # v1 | |
| with: | |
| app-id: ${{ secrets.ADMIN_APP_ID }} | |
| private-key: ${{ secrets.ADMIN_APP_PRIVATE_KEY }} | |
| owner: kernel | |
| repositories: kernel-python-sdk | |
| permission-contents: write | |
| permission-issues: write | |
| permission-pull-requests: write | |
| permission-workflows: write | |
| - name: Set up Node | |
| uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 | |
| with: | |
| node-version: '18.20.2' | |
| - name: Set up pnpm | |
| uses: pnpm/action-setup@f40ffcd9367d9f12939873eb1018b921a783ffaa # v4 | |
| with: | |
| version: '9.11.0' | |
| run_install: false | |
| - name: Build pinned release tooling | |
| id: tooling | |
| env: | |
| RELEASE_PLEASE_DIR: ${{ runner.temp }}/release-please | |
| RELEASE_PLEASE_SHA: a116e1e520e0f87824acf46a2e79c91d41e819d7 | |
| run: | | |
| set -euo pipefail | |
| rm -rf "$RELEASE_PLEASE_DIR" | |
| git init "$RELEASE_PLEASE_DIR" | |
| git -C "$RELEASE_PLEASE_DIR" remote add origin https://github.com/stainless-api/release-please.git | |
| git -C "$RELEASE_PLEASE_DIR" fetch --depth=1 origin "$RELEASE_PLEASE_SHA" | |
| git -C "$RELEASE_PLEASE_DIR" checkout --detach FETCH_HEAD | |
| pnpm --dir "$RELEASE_PLEASE_DIR" install --frozen-lockfile | |
| pnpm --dir "$RELEASE_PLEASE_DIR" build | |
| echo "cli=$RELEASE_PLEASE_DIR/build/src/bin/release-please.js" >> "$GITHUB_OUTPUT" | |
| - name: Open or update the release PR | |
| if: github.ref_name == 'next' | |
| env: | |
| GH_TOKEN: ${{ steps.release-token.outputs.token }} | |
| RELEASE_PLEASE: ${{ steps.tooling.outputs.cli }} | |
| run: | | |
| set -euo pipefail | |
| node "$RELEASE_PLEASE" release-pr \ | |
| --repo-url "$GITHUB_REPOSITORY" \ | |
| --token "$GH_TOKEN" \ | |
| --target-branch main \ | |
| --changes-branch next | |
| - name: Remove the legacy promotion PR | |
| if: github.ref_name == 'next' | |
| env: | |
| GH_TOKEN: ${{ steps.release-token.outputs.token }} | |
| run: | | |
| set -euo pipefail | |
| legacy=$(gh pr list --repo "$GITHUB_REPOSITORY" --head stainless/release \ | |
| --state open --json number --jq '.[].number') | |
| for pr in $legacy; do | |
| gh pr close "$pr" --repo "$GITHUB_REPOSITORY" \ | |
| --comment "Superseded by the versioned release PR from next to main." | |
| done | |
| gh api -X DELETE "repos/$GITHUB_REPOSITORY/git/refs/heads/stainless/release" >/dev/null 2>&1 || true | |
| - name: Create the GitHub release | |
| if: github.ref_name == 'main' | |
| env: | |
| GH_TOKEN: ${{ steps.release-token.outputs.token }} | |
| RELEASE_PLEASE: ${{ steps.tooling.outputs.cli }} | |
| run: | | |
| set -euo pipefail | |
| node "$RELEASE_PLEASE" github-release \ | |
| --repo-url "$GITHUB_REPOSITORY" \ | |
| --token "$GH_TOKEN" \ | |
| --target-branch main |