chore(release): bump telemetry-fixed SDK packages by a minor version #17
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
| # Publish @betterdb/semantic-cache to npm | |
| # | |
| # Required secrets: | |
| # NPM_TOKEN — npmjs.com automation token with publish access to @betterdb/semantic-cache | |
| name: Publish Semantic Cache | |
| on: | |
| push: | |
| tags: | |
| - 'semantic-cache-v*' | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version to publish (e.g. 0.1.0)' | |
| required: true | |
| type: string | |
| skip_npm: | |
| description: 'Skip npm publish' | |
| type: boolean | |
| default: false | |
| jobs: | |
| publish-npm: | |
| if: ${{ !inputs.skip_npm }} | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| id-token: write | |
| outputs: | |
| version: ${{ steps.version.outputs.version }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Get pnpm store directory | |
| shell: bash | |
| run: | | |
| echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
| - name: Setup pnpm cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ env.STORE_PATH }} | |
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm-store- | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Resolve version | |
| id: version | |
| env: | |
| INPUT_VERSION: ${{ inputs.version }} | |
| run: | | |
| if [ -n "$INPUT_VERSION" ]; then | |
| echo "version=$INPUT_VERSION" >> $GITHUB_OUTPUT | |
| else | |
| # semantic-cache-v0.1.0 → 0.1.0 | |
| echo "version=${GITHUB_REF_NAME#semantic-cache-v}" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Update package.json version | |
| env: | |
| VERSION: ${{ steps.version.outputs.version }} | |
| run: | | |
| cd packages/semantic-cache | |
| node -e " | |
| const fs = require('fs'); | |
| const pkg = JSON.parse(fs.readFileSync('./package.json', 'utf8')); | |
| pkg.version = process.env.VERSION; | |
| fs.writeFileSync('./package.json', JSON.stringify(pkg, null, 2) + '\n'); | |
| " | |
| - name: Build semantic-cache | |
| env: | |
| POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }} | |
| POSTHOG_HOST: ${{ secrets.POSTHOG_HOST }} | |
| REQUIRE_TELEMETRY_KEY: '1' | |
| run: pnpm --filter @betterdb/semantic-cache... build | |
| - name: Verify build | |
| run: | | |
| test -f packages/semantic-cache/dist/index.js | |
| test -f packages/semantic-cache/dist/index.d.ts | |
| - name: Prepare for publishing | |
| run: | | |
| cd packages/semantic-cache | |
| node -e " | |
| const fs = require('fs'); | |
| const pkg = JSON.parse(fs.readFileSync('./package.json', 'utf8')); | |
| delete pkg.devDependencies; | |
| fs.writeFileSync('./package.json', JSON.stringify(pkg, null, 2) + '\n'); | |
| " | |
| - name: Verify valkey-search-kit is published | |
| run: | | |
| KIT_VERSION=$(node -p "require('./packages/valkey-search-kit/package.json').version") | |
| npm view "@betterdb/valkey-search-kit@$KIT_VERSION" version \ | |
| || { echo "::error::@betterdb/valkey-search-kit@$KIT_VERSION is not on npm — publish the kit first (tag valkey-search-kit-v$KIT_VERSION)"; exit 1; } | |
| - name: Publish to npm | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: cd packages/semantic-cache && pnpm publish --provenance --access public --no-git-checks | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: semantic-cache-v${{ steps.version.outputs.version }} | |
| name: Semantic Cache v${{ steps.version.outputs.version }} | |
| draft: false | |
| prerelease: ${{ contains(steps.version.outputs.version, '-') }} | |
| generate_release_notes: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| verify: | |
| needs: publish-npm | |
| runs-on: ubuntu-latest | |
| if: ${{ !inputs.skip_npm }} | |
| steps: | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Verify npm package (with retry) | |
| env: | |
| VERSION: ${{ needs.publish-npm.outputs.version }} | |
| run: | | |
| for i in 1 2 3 4 5; do | |
| if npm view "@betterdb/semantic-cache@$VERSION" version; then | |
| echo "Package verified successfully" | |
| exit 0 | |
| fi | |
| echo "Attempt $i: package not yet available, retrying in 30s..." | |
| sleep 30 | |
| done | |
| echo "Package not available after 5 attempts" | |
| exit 1 |