Repository navigation
Release #29
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: write | |
| id-token: write | |
| jobs: | |
| publish-npm: | |
| name: Publish to npm | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - uses: pnpm/action-setup@v6 | |
| with: | |
| version: 10.33.0 | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24 | |
| cache: pnpm | |
| - name: Use latest npm for trusted publishing | |
| run: npm install -g npm@latest | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Validate OSS release surface | |
| run: | | |
| pnpm lint | |
| pnpm public:copy-scan | |
| pnpm public:git-surface | |
| pnpm test | |
| pnpm build | |
| pnpm oss:validate | |
| pnpm public:smoke | |
| pnpm --filter @martinloop/mcp lint | |
| pnpm --filter @martinloop/mcp test | |
| pnpm --filter @martinloop/mcp build | |
| pnpm --filter @martinloop/mcp smoke:pack | |
| pnpm --filter @martinloop/mcp smoke:published:pack | |
| pnpm --filter @martinloop/mcp verify:release | |
| node ./scripts/root-release-guard.mjs --tag "${GITHUB_REF_NAME}" --pack | |
| - name: Pack root tarball | |
| id: root-pack | |
| run: | | |
| PACK_RESULT="$(node ./scripts/pack-root-release.mjs --output-dir dist-release)" | |
| printf '%s\n' "$PACK_RESULT" > dist-release/pack-result.json | |
| TARBALL="$(node -e "const fs = require('fs'); const data = JSON.parse(fs.readFileSync('dist-release/pack-result.json', 'utf8')); process.stdout.write(data.tarballPath);")" | |
| echo "tarball=${TARBALL}" >> "$GITHUB_OUTPUT" | |
| - name: Read package version | |
| id: package-version | |
| run: | | |
| VERSION="$(node -p "require('./package.json').version")" | |
| echo "version=${VERSION}" >> "$GITHUB_OUTPUT" | |
| - name: Extract changelog entry | |
| id: changelog | |
| run: | | |
| BODY="$(node ./scripts/extract-changelog-entry.mjs --version "${{ steps.package-version.outputs.version }}")" | |
| { | |
| echo "body<<EOF_CHANGELOG" | |
| printf '%s\n' "$BODY" | |
| echo "EOF_CHANGELOG" | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Check npm for existing version | |
| id: npm-version | |
| run: | | |
| if npm view "martin-loop@${{ steps.package-version.outputs.version }}" version >/dev/null 2>&1; then | |
| echo "exists=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "exists=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Publish to npm | |
| if: steps.npm-version.outputs.exists != 'true' | |
| run: npm publish "${{ steps.root-pack.outputs.tarball }}" --access public --provenance | |
| - name: Skip duplicate npm publish | |
| if: steps.npm-version.outputs.exists == 'true' | |
| run: echo "martin-loop@${{ steps.package-version.outputs.version }} already exists on npm; skipping publish." | |
| - name: Verify npm availability | |
| run: | | |
| for attempt in 1 2 3 4 5; do | |
| if npm view "martin-loop@${{ steps.package-version.outputs.version }}" version >/dev/null 2>&1; then | |
| exit 0 | |
| fi | |
| sleep $((attempt * 5)) | |
| done | |
| echo "martin-loop@${{ steps.package-version.outputs.version }} did not become visible on npm in time." | |
| exit 1 | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v3 | |
| with: | |
| files: ${{ steps.root-pack.outputs.tarball }} | |
| body: ${{ steps.changelog.outputs.body }} |