|
| 1 | +name: release-prod |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + |
| 7 | +# Production release: every merge to `main` cuts a stable release. |
| 8 | +# |
| 9 | +# Versioning: uses package.json version EXACTLY. The developer must bump |
| 10 | +# package.json on the staging→main PR before merging. If the tag already |
| 11 | +# exists (i.e. version wasn't bumped), the workflow fails — explicit, not |
| 12 | +# silent. |
| 13 | +# |
| 14 | +# This is a deliberate gate: production releases require a thoughtful |
| 15 | +# version bump, not auto-numbering. Beta releases auto-version because |
| 16 | +# they're meant to be many; prod releases should be intentional. |
| 17 | + |
| 18 | +permissions: |
| 19 | + contents: write |
| 20 | + |
| 21 | +jobs: |
| 22 | + release: |
| 23 | + runs-on: ubuntu-22.04 |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@v4 |
| 26 | + with: |
| 27 | + fetch-depth: 0 |
| 28 | + |
| 29 | + - uses: actions/setup-node@v4 |
| 30 | + with: |
| 31 | + node-version: 20 |
| 32 | + |
| 33 | + - name: Install plugin deps |
| 34 | + run: npm ci |
| 35 | + |
| 36 | + - name: Lint |
| 37 | + run: npm run lint |
| 38 | + |
| 39 | + - name: Test plugin |
| 40 | + run: npm test -- --coverage |
| 41 | + |
| 42 | + - name: Verify per-file coverage gate |
| 43 | + run: node scripts/check-coverage.mjs |
| 44 | + |
| 45 | + - name: Install MCP deps |
| 46 | + working-directory: mcp/lua-platform |
| 47 | + run: npm ci |
| 48 | + |
| 49 | + - name: Test MCP |
| 50 | + working-directory: mcp/lua-platform |
| 51 | + run: npm test |
| 52 | + |
| 53 | + - name: Build MCP bundle |
| 54 | + working-directory: mcp/lua-platform |
| 55 | + run: npm run build |
| 56 | + |
| 57 | + - name: Verify bundle size |
| 58 | + run: node scripts/check-bundle-size.mjs |
| 59 | + |
| 60 | + - name: Read version from package.json |
| 61 | + id: version |
| 62 | + run: | |
| 63 | + VERSION=$(node -p "require('./package.json').version") |
| 64 | + if [[ "${VERSION}" == *"-beta"* || "${VERSION}" == *"-rc"* || "${VERSION}" == *"-alpha"* ]]; then |
| 65 | + echo "::error::Production release requires a stable version in package.json (no -beta/-rc/-alpha suffix). Got: ${VERSION}" |
| 66 | + exit 1 |
| 67 | + fi |
| 68 | + echo "tag=v${VERSION}" >> "$GITHUB_OUTPUT" |
| 69 | + echo "version=${VERSION}" >> "$GITHUB_OUTPUT" |
| 70 | + echo "Production version: ${VERSION}" |
| 71 | +
|
| 72 | + - name: Verify tag does not already exist |
| 73 | + run: | |
| 74 | + if git rev-parse "${{ steps.version.outputs.tag }}" >/dev/null 2>&1; then |
| 75 | + echo "::error::Tag ${{ steps.version.outputs.tag }} already exists. Bump package.json version before merging to main." |
| 76 | + exit 1 |
| 77 | + fi |
| 78 | +
|
| 79 | + - name: Build release tarball |
| 80 | + # scripts/pack.mjs handles the MCP dist/ inclusion. Production |
| 81 | + # tags use the package.json version verbatim — no override needed. |
| 82 | + run: | |
| 83 | + node scripts/pack.mjs |
| 84 | + TARBALL="claude-code-lua-plugin-${{ steps.version.outputs.version }}.tar.gz" |
| 85 | + ls -lh "${TARBALL}" |
| 86 | + echo "TARBALL=${TARBALL}" >> "$GITHUB_ENV" |
| 87 | +
|
| 88 | + - name: Create GitHub release |
| 89 | + uses: softprops/action-gh-release@v2 |
| 90 | + with: |
| 91 | + tag_name: ${{ steps.version.outputs.tag }} |
| 92 | + name: ${{ steps.version.outputs.tag }} |
| 93 | + prerelease: false |
| 94 | + generate_release_notes: true |
| 95 | + target_commitish: main |
| 96 | + files: ${{ env.TARBALL }} |
0 commit comments