Release #186
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 | |
| on: | |
| repository_dispatch: | |
| types: [openapi-updated] | |
| schedule: | |
| - cron: '0 6 * * *' | |
| workflow_dispatch: | |
| inputs: | |
| version_bump: | |
| description: 'patch | minor | major' | |
| required: false | |
| default: 'patch' | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v7 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| # Release tags are the ledger the gate below reads. The default shallow | |
| # checkout fetches none of them, which would make every run look like a | |
| # first release. | |
| fetch-depth: 0 | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: '24' | |
| registry-url: 'https://registry.npmjs.org' | |
| - uses: oven-sh/setup-bun@v2 | |
| - run: bun install --frozen-lockfile | |
| # Also runs sync-docs internally (scripts/generate.ts), so README/AGENTS/llms-full | |
| # are already refreshed by the time the commit step stages them. | |
| - name: Regenerate SDK | |
| run: bun run generate | |
| # Compare against the last RELEASED tag, never against the working tree. | |
| # "Did anything change since the last commit" is the wrong question: commit a | |
| # regeneration by hand and the next run sees a clean tree, reports success and | |
| # silently skips every publish step below, leaving the registry behind forever. | |
| # The tag cannot lie, because whatever is published is what that tag built. | |
| # The spec is the only generator input, so it is the only thing worth diffing; | |
| # a generator version bump changes the output without touching the spec and is | |
| # released deliberately through workflow_dispatch. | |
| - name: Is the published release built from the current spec? | |
| id: diff | |
| run: | | |
| LAST=$(git describe --tags --abbrev=0 --match 'v*' 2>/dev/null || true) | |
| if [ -z "$LAST" ]; then | |
| echo "changed=true" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| git show "$LAST:specs/openapi.json" | jq -cS . > "$RUNNER_TEMP/released-spec.json" | |
| jq -cS . specs/openapi.json > "$RUNNER_TEMP/current-spec.json" | |
| if cmp -s "$RUNNER_TEMP/released-spec.json" "$RUNNER_TEMP/current-spec.json"; then | |
| echo "changed=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "changed=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Build | |
| if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch' | |
| run: bun run build | |
| - name: Test | |
| if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch' | |
| run: bun run test | |
| - name: Bump version and rebuild | |
| id: bump | |
| if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch' | |
| run: | | |
| npm version ${{ github.event.inputs.version_bump || 'patch' }} --no-git-tag-version | |
| VERSION=$(node -p "require('./package.json').version") | |
| echo "export const VERSION = '$VERSION';" > src/version.ts | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| bun run build | |
| - name: Publish to npm | |
| if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch' | |
| run: | | |
| npm install -g npm@latest | |
| npm publish --access public --provenance | |
| - name: Commit, tag, push | |
| if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| VERSION=$(node -p "require('./package.json').version") | |
| git add package.json src/version.ts specs/openapi.json src/ README.md AGENTS.md docs/llms-full.txt | |
| git commit -m "release: v$VERSION" | |
| git tag "v$VERSION" | |
| git push --follow-tags | |
| - name: Create GitHub release | |
| if: steps.diff.outputs.changed == 'true' || github.event_name == 'workflow_dispatch' | |
| uses: softprops/action-gh-release@v3 | |
| with: | |
| tag_name: v${{ steps.bump.outputs.version }} | |
| generate_release_notes: true | |
| make_latest: 'true' |