chore: release v0.2.0 #6
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: ["v*"] | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: release-${{ github.ref }} | |
| cancel-in-progress: false | |
| jobs: | |
| verify-and-build: | |
| name: Verify & Build | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node 20 | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| cache: "npm" | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Typecheck + coverage + build | |
| env: | |
| METRILLM_POSTHOG_KEY: ${{ secrets.METRILLM_POSTHOG_KEY }} | |
| run: npm run ci:verify | |
| - name: Upload build artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist/ | |
| retention-days: 1 | |
| publish-npm: | |
| name: Publish to npm | |
| needs: verify-and-build | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| environment: npm | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node 20 | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| cache: "npm" | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Download verified build artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist/ | |
| - name: Publish with provenance | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: npm publish --access public --provenance || { [ $? -eq 1 ] && npm view metrillm@"$(node -p 'require("./package.json").version')" version && echo "Version already published, skipping" || exit 1; } | |
| publish-mcp: | |
| name: Publish MCP server to npm | |
| needs: verify-and-build | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| environment: npm | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node 20 | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| cache: "npm" | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Install MCP dependencies | |
| working-directory: mcp | |
| run: npm ci | |
| - name: Build MCP server | |
| working-directory: mcp | |
| run: npm run build | |
| - name: Publish MCP with provenance | |
| working-directory: mcp | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: npm publish --access public --provenance || { [ $? -eq 1 ] && npm view metrillm-mcp@"$(node -p 'require("./package.json").version')" version && echo "Version already published, skipping" || exit 1; } | |
| github-release: | |
| name: GitHub Release | |
| needs: publish-npm | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Extract version from tag | |
| id: version | |
| run: echo "version=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT" | |
| - name: Extract changelog for this version | |
| id: changelog | |
| run: | | |
| version="${GITHUB_REF#refs/tags/v}" | |
| # Escape regex metacharacters in version string | |
| escaped=$(printf '%s' "$version" | sed 's/[].[\\*^$+?(){}|]/\\&/g') | |
| changelog=$(awk "/^## \[${escaped}\]/{found=1; next} /^## \[/{if(found) exit} found{print}" CHANGELOG.md 2>/dev/null || true) | |
| if [ -z "$changelog" ]; then | |
| changelog="See [CHANGELOG.md](CHANGELOG.md) for details." | |
| fi | |
| EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) | |
| echo "body<<$EOF" >> "$GITHUB_OUTPUT" | |
| echo "$changelog" >> "$GITHUB_OUTPUT" | |
| echo "$EOF" >> "$GITHUB_OUTPUT" | |
| - name: Create GitHub Release | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| RELEASE_BODY: ${{ steps.changelog.outputs.body }} | |
| run: | | |
| printf '%s\n' "$RELEASE_BODY" > /tmp/release-notes.md | |
| gh release create "${{ steps.version.outputs.version }}" \ | |
| --title "${{ steps.version.outputs.version }}" \ | |
| --notes-file /tmp/release-notes.md \ | |
| --verify-tag | |
| smoke-test: | |
| name: Post-publish smoke test | |
| needs: publish-npm | |
| runs-on: ${{ matrix.os }} | |
| timeout-minutes: 5 | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| steps: | |
| - name: Setup Node 20 | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| - name: Extract version from tag | |
| id: version | |
| shell: bash | |
| run: echo "version=${GITHUB_REF#refs/tags/v}" >> "$GITHUB_OUTPUT" | |
| - name: Wait for npm registry propagation | |
| shell: bash | |
| run: | | |
| for i in $(seq 1 18); do | |
| if npm view "metrillm@${{ steps.version.outputs.version }}" version 2>/dev/null | grep -q "${{ steps.version.outputs.version }}"; then | |
| echo "Version ${{ steps.version.outputs.version }} available on npm" | |
| exit 0 | |
| fi | |
| echo "Waiting for npm propagation... (attempt $i/18)" | |
| sleep 10 | |
| done | |
| echo "::warning::Version not yet visible on npm after 3 minutes" | |
| exit 1 | |
| - name: Verify npx install and --help | |
| shell: bash | |
| run: npx "metrillm@${{ steps.version.outputs.version }}" --help |