Merge pull request #20 from OpenRouterTeam/export-missing-sdk-types #17
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: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| inputs: | |
| mode: | |
| description: > | |
| Release mode: | |
| - "version" — Creates a "Version Packages" PR that bumps versions and | |
| updates CHANGELOG.md based on pending changesets. Run this first. | |
| - "publish" — Publishes the package to npm with provenance. Only run | |
| this AFTER the Version Packages PR has been merged to main. | |
| NOTE: @openrouter/agent releases must be coordinated with @openrouter/sdk | |
| because callModel changes are typically coupled with SDK type changes. | |
| required: true | |
| type: choice | |
| options: | |
| - version | |
| - publish | |
| default: version | |
| dry-run: | |
| description: > | |
| Dry run: If enabled, simulates the release without making any changes. | |
| Useful for verifying what would happen before committing to a release. | |
| required: false | |
| type: boolean | |
| default: false | |
| permissions: | |
| contents: write # For creating releases and the Version Packages PR | |
| pull-requests: write # For creating/updating the Version Packages PR | |
| id-token: write # For npm provenance signing | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| environment: npm-publish | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: pnpm/action-setup@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: pnpm | |
| registry-url: https://registry.npmjs.org | |
| - run: pnpm install --frozen-lockfile | |
| - run: pnpm run build | |
| - run: pnpm run test | |
| - name: Check for pending changesets | |
| if: github.event_name == 'push' | |
| id: changesets | |
| run: | | |
| if ls .changeset/*.md 1>/dev/null 2>&1; then | |
| echo "pending=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "pending=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Create Version Packages PR | |
| if: > | |
| (github.event_name == 'push' && steps.changesets.outputs.pending == 'true') || | |
| (github.event_name == 'workflow_dispatch' && inputs.mode == 'version') | |
| uses: changesets/action@v1 | |
| with: | |
| title: "chore: version packages" | |
| commit: "chore: version packages" | |
| publish: pnpm publish --no-git-checks --provenance --access public | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Publish to npm | |
| if: > | |
| (github.event_name == 'push' && steps.changesets.outputs.pending == 'false') || | |
| (github.event_name == 'workflow_dispatch' && inputs.mode == 'publish' && !inputs.dry-run) | |
| run: pnpm publish --no-git-checks --provenance --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Publish to npm (dry run) | |
| if: github.event_name == 'workflow_dispatch' && inputs.mode == 'publish' && inputs.dry-run | |
| run: pnpm publish --no-git-checks --provenance --access public --dry-run | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |