Merge pull request #14 from codebase/codex/oauth-web-search #65
Workflow file for this run
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: | |
| tags: | |
| - "v2.*" | |
| # Older v1.* tags are preserved on the anthropic-support branch and do | |
| # not trigger this workflow. The v2.* prefix is the trigger so we never | |
| # accidentally re-publish v1 from this codebase. | |
| permissions: | |
| contents: write | |
| id-token: write # for npm provenance attestation | |
| jobs: | |
| publish: | |
| name: Publish to npm | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| cache: npm | |
| registry-url: "https://registry.npmjs.org/" | |
| - name: Install | |
| run: npm ci | |
| - name: Lint, typecheck, test | |
| run: npm run check | |
| - name: Verify tag matches package.json version | |
| run: | | |
| PKG_VERSION="$(node -p "require('./package.json').version")" | |
| TAG_VERSION="${GITHUB_REF_NAME#v}" | |
| if [ "$PKG_VERSION" != "$TAG_VERSION" ]; then | |
| echo "::error::Tag $GITHUB_REF_NAME does not match package.json version $PKG_VERSION" | |
| exit 1 | |
| fi | |
| - name: Verify npm provenance repository | |
| run: | | |
| REPOSITORY_URL="$(node -p "require('./package.json').repository.url")" | |
| EXPECTED="git+https://github.com/${GITHUB_REPOSITORY}.git" | |
| if [ "$REPOSITORY_URL" != "$EXPECTED" ]; then | |
| echo "::error::package.json repository.url is $REPOSITORY_URL; expected $EXPECTED for npm provenance" | |
| exit 1 | |
| fi | |
| - name: Determine npm dist-tag | |
| id: disttag | |
| run: | | |
| # 2.0.0 → latest | |
| # 2.0.0-rc.1 → next | |
| # 2.0.0-pre.0 → pre | |
| # anything else with prerelease suffix → next (safe default) | |
| VERSION="${GITHUB_REF_NAME#v}" | |
| if [[ "$VERSION" == *-pre.* ]]; then | |
| TAG="pre" | |
| elif [[ "$VERSION" == *-* ]]; then | |
| TAG="next" | |
| else | |
| TAG="latest" | |
| fi | |
| echo "tag=$TAG" >> "$GITHUB_OUTPUT" | |
| echo "Selected dist-tag: $TAG for version $VERSION" | |
| - name: Publish to npm | |
| # Pass --tag so pre-releases never become `latest`, even | |
| # transiently. npm interprets the absence of --tag as `latest`. | |
| run: npm publish --provenance --tag "${{ steps.disttag.outputs.tag }}" | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ github.ref_name }} | |
| name: ${{ github.ref_name }} | |
| generate_release_notes: true | |
| prerelease: ${{ contains(github.ref_name, '-') }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |