|
| 1 | +name: Claude Code Plugin Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'package-claude-code/v*' |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + verify: |
| 14 | + name: Verify & Build |
| 15 | + runs-on: ubuntu-latest |
| 16 | + timeout-minutes: 10 |
| 17 | + defaults: |
| 18 | + run: |
| 19 | + working-directory: src/packages/claude-code |
| 20 | + steps: |
| 21 | + - name: Checkout repository |
| 22 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 |
| 23 | + |
| 24 | + - name: Set up Node.js |
| 25 | + uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6 |
| 26 | + with: |
| 27 | + node-version: '20' |
| 28 | + |
| 29 | + - name: Extract version from package.json |
| 30 | + id: pkg_version |
| 31 | + run: | |
| 32 | + VERSION=$(node -p "require('./package.json').version") |
| 33 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 34 | + echo "Package version: $VERSION" |
| 35 | +
|
| 36 | + - name: Extract version from tag |
| 37 | + id: tag_version |
| 38 | + env: |
| 39 | + GIT_REF: ${{ github.ref }} |
| 40 | + run: | |
| 41 | + if [[ "$GIT_REF" == refs/tags/* ]]; then |
| 42 | + TAG_NAME=${GIT_REF#refs/tags/package-claude-code/v} |
| 43 | + echo "version=$TAG_NAME" >> $GITHUB_OUTPUT |
| 44 | + echo "Tag version: $TAG_NAME" |
| 45 | + else |
| 46 | + echo "version=" >> $GITHUB_OUTPUT |
| 47 | + fi |
| 48 | +
|
| 49 | + - name: Verify tag matches package.json |
| 50 | + if: steps.tag_version.outputs.version != '' |
| 51 | + env: |
| 52 | + PKG_VERSION: ${{ steps.pkg_version.outputs.version }} |
| 53 | + TAG_VERSION: ${{ steps.tag_version.outputs.version }} |
| 54 | + run: | |
| 55 | + if [ "$PKG_VERSION" != "$TAG_VERSION" ]; then |
| 56 | + echo "Error: package.json version ($PKG_VERSION) does not match tag version ($TAG_VERSION)" |
| 57 | + exit 1 |
| 58 | + fi |
| 59 | + echo "Version match: $PKG_VERSION" |
| 60 | +
|
| 61 | + - name: Verify plugin.json version |
| 62 | + env: |
| 63 | + PKG_VERSION: ${{ steps.pkg_version.outputs.version }} |
| 64 | + run: | |
| 65 | + PLUGIN_VERSION=$(node -p "require('./plugin/.claude-plugin/plugin.json').version") |
| 66 | + if [ "$PKG_VERSION" != "$PLUGIN_VERSION" ]; then |
| 67 | + echo "Error: plugin.json version ($PLUGIN_VERSION) does not match package.json ($PKG_VERSION)" |
| 68 | + echo "Hint: run 'npm run release -- $PKG_VERSION' to sync all versions" |
| 69 | + exit 1 |
| 70 | + fi |
| 71 | + echo "plugin.json version: $PLUGIN_VERSION ✓" |
| 72 | +
|
| 73 | + - name: Verify marketplace.json version |
| 74 | + env: |
| 75 | + PKG_VERSION: ${{ steps.pkg_version.outputs.version }} |
| 76 | + run: | |
| 77 | + MKT_VERSION=$(node -p "require('../../../.claude-plugin/marketplace.json').plugins.find(p => p.name === 'acontext').version") |
| 78 | + if [ "$PKG_VERSION" != "$MKT_VERSION" ]; then |
| 79 | + echo "Error: marketplace.json version ($MKT_VERSION) does not match package.json ($PKG_VERSION)" |
| 80 | + echo "Hint: run 'npm run release -- $PKG_VERSION' to sync all versions" |
| 81 | + exit 1 |
| 82 | + fi |
| 83 | + echo "marketplace.json version: $MKT_VERSION ✓" |
| 84 | +
|
| 85 | + - name: Install dependencies |
| 86 | + run: npm install |
| 87 | + |
| 88 | + - name: Run tests |
| 89 | + run: npm test |
| 90 | + |
| 91 | + - name: Save committed bundle checksums |
| 92 | + run: | |
| 93 | + sha256sum plugin/scripts/mcp-server.cjs plugin/scripts/hook-handler.cjs > /tmp/committed-checksums.txt |
| 94 | + echo "Committed checksums:" |
| 95 | + cat /tmp/committed-checksums.txt |
| 96 | +
|
| 97 | + - name: Build |
| 98 | + run: npm run build |
| 99 | + |
| 100 | + - name: Verify build output |
| 101 | + run: | |
| 102 | + node -e " |
| 103 | + const fs = require('fs'); |
| 104 | + const files = ['plugin/scripts/mcp-server.cjs', 'plugin/scripts/hook-handler.cjs']; |
| 105 | + for (const f of files) { |
| 106 | + if (!fs.existsSync(f)) { console.error('Missing: ' + f); process.exit(1); } |
| 107 | + const stat = fs.statSync(f); |
| 108 | + if (stat.size < 1000) { console.error('Suspiciously small: ' + f + ' (' + stat.size + ' bytes)'); process.exit(1); } |
| 109 | + console.log('OK: ' + f + ' (' + (stat.size / 1024).toFixed(0) + ' KB)'); |
| 110 | + } |
| 111 | + " |
| 112 | +
|
| 113 | + - name: Verify bundles match committed artifacts |
| 114 | + run: | |
| 115 | + sha256sum plugin/scripts/mcp-server.cjs plugin/scripts/hook-handler.cjs > /tmp/rebuilt-checksums.txt |
| 116 | + echo "Rebuilt checksums:" |
| 117 | + cat /tmp/rebuilt-checksums.txt |
| 118 | + if ! diff /tmp/committed-checksums.txt /tmp/rebuilt-checksums.txt; then |
| 119 | + echo "" |
| 120 | + echo "Error: Committed bundles do not match a clean rebuild." |
| 121 | + echo "Hint: run 'npm run release -- X.Y.Z' to rebuild and commit the updated bundles." |
| 122 | + exit 1 |
| 123 | + fi |
| 124 | + echo "Bundles match ✓" |
| 125 | +
|
| 126 | + create-release: |
| 127 | + name: Create GitHub Release |
| 128 | + runs-on: ubuntu-latest |
| 129 | + timeout-minutes: 10 |
| 130 | + needs: verify |
| 131 | + steps: |
| 132 | + - name: Checkout repository |
| 133 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 |
| 134 | + |
| 135 | + - name: Extract version from tag |
| 136 | + id: version |
| 137 | + env: |
| 138 | + GIT_REF: ${{ github.ref }} |
| 139 | + run: | |
| 140 | + TAG_NAME=${GIT_REF#refs/tags/package-claude-code/v} |
| 141 | + echo "version=$TAG_NAME" >> $GITHUB_OUTPUT |
| 142 | +
|
| 143 | + - name: Generate Changelog |
| 144 | + env: |
| 145 | + VERSION: ${{ steps.version.outputs.version }} |
| 146 | + CHANGELOG_FILE: ${{ github.workspace }}-CHANGELOG.txt |
| 147 | + run: | |
| 148 | + cat > "$CHANGELOG_FILE" << EOF |
| 149 | + # Claude Code Plugin v${VERSION} |
| 150 | +
|
| 151 | + ## Installation |
| 152 | +
|
| 153 | + \`\`\`bash |
| 154 | + claude mcp add-from-marketplace acontext --publisher memodb-io |
| 155 | + \`\`\` |
| 156 | +
|
| 157 | + ## Release Checklist |
| 158 | + - [x] Version synced across package.json, plugin.json, marketplace.json |
| 159 | + - [x] Tests passed |
| 160 | + - [x] Plugin bundles built and verified |
| 161 | + EOF |
| 162 | +
|
| 163 | + - name: Create Release |
| 164 | + uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2 |
| 165 | + with: |
| 166 | + body_path: ${{ github.workspace }}-CHANGELOG.txt |
0 commit comments