|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + # Triggers when release-please creates a release |
| 5 | + release: |
| 6 | + types: [published] |
| 7 | + |
| 8 | + # Allow manual trigger for emergency releases |
| 9 | + workflow_dispatch: |
| 10 | + inputs: |
| 11 | + skip_npm: |
| 12 | + description: 'Skip npm publish' |
| 13 | + required: false |
| 14 | + default: false |
| 15 | + type: boolean |
| 16 | + |
| 17 | +permissions: |
| 18 | + contents: write |
| 19 | + issues: write |
| 20 | + pull-requests: write |
| 21 | + id-token: write |
| 22 | + |
| 23 | +jobs: |
| 24 | + publish: |
| 25 | + name: Build & Publish |
| 26 | + runs-on: ubuntu-latest |
| 27 | + if: github.event_name == 'release' || github.event_name == 'workflow_dispatch' |
| 28 | + |
| 29 | + steps: |
| 30 | + - name: Checkout code |
| 31 | + uses: actions/checkout@v4 |
| 32 | + with: |
| 33 | + fetch-depth: 0 |
| 34 | + ref: prod |
| 35 | + |
| 36 | + - name: Setup Node.js |
| 37 | + uses: actions/setup-node@v4 |
| 38 | + with: |
| 39 | + node-version: '20.x' |
| 40 | + registry-url: 'https://registry.npmjs.org' |
| 41 | + cache: 'npm' |
| 42 | + |
| 43 | + - name: Configure Git |
| 44 | + run: | |
| 45 | + git config user.name "github-actions[bot]" |
| 46 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 47 | +
|
| 48 | + - name: Install dependencies |
| 49 | + run: npm ci |
| 50 | + |
| 51 | + - name: Run validation |
| 52 | + run: npm run validate |
| 53 | + |
| 54 | + - name: Build production with fresh docs |
| 55 | + run: npm run build:prod |
| 56 | + env: |
| 57 | + NODE_OPTIONS: --max-old-space-size=6144 |
| 58 | + |
| 59 | + - name: Generate database manifest |
| 60 | + run: | |
| 61 | + VERSION=$(node -p "require('./package.json').version") |
| 62 | + echo "📋 Generating manifest for version $VERSION" |
| 63 | + npm run db:manifest -- --version "$VERSION" --type full --changelog "Full documentation index update for v$VERSION" |
| 64 | +
|
| 65 | + - name: Publish to npm |
| 66 | + if: ${{ github.event.inputs.skip_npm != 'true' }} |
| 67 | + run: npm publish --provenance --access public |
| 68 | + |
| 69 | + - name: Prepare database release artifacts |
| 70 | + run: | |
| 71 | + VERSION=$(node -p "require('./package.json').version") |
| 72 | + mkdir -p release-artifacts |
| 73 | + cp data/mcmodding-docs.db release-artifacts/ |
| 74 | + cp data/manifest.json release-artifacts/db-manifest.json |
| 75 | + echo "📦 Release artifacts:" |
| 76 | + ls -lh release-artifacts/ |
| 77 | +
|
| 78 | + - name: Upload database to release |
| 79 | + uses: softprops/action-gh-release@v1 |
| 80 | + with: |
| 81 | + tag_name: ${{ github.event.release.tag_name || format('v{0}', env.VERSION) }} |
| 82 | + files: | |
| 83 | + release-artifacts/mcmodding-docs.db |
| 84 | + release-artifacts/db-manifest.json |
| 85 | + append_body: true |
| 86 | + body: | |
| 87 | +
|
| 88 | + --- |
| 89 | +
|
| 90 | + ## 🗄️ Database Release |
| 91 | +
|
| 92 | + | File | Description | |
| 93 | + |------|-------------| |
| 94 | + | `mcmodding-docs.db` | Complete documentation index with semantic embeddings | |
| 95 | + | `db-manifest.json` | Version manifest with SHA256 hash verification | |
| 96 | +
|
| 97 | + **Auto-Update:** The MCP will automatically detect and download this version on next startup. |
| 98 | +
|
| 99 | + env: |
| 100 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 101 | + VERSION: ${{ github.event.release.tag_name }} |
| 102 | + |
| 103 | + - name: Log release summary |
| 104 | + run: | |
| 105 | + VERSION=$(node -p "require('./package.json').version") |
| 106 | + echo "## 🎉 Release Published Successfully!" >> $GITHUB_STEP_SUMMARY |
| 107 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 108 | + echo "| Component | Status |" >> $GITHUB_STEP_SUMMARY |
| 109 | + echo "|-----------|--------|" >> $GITHUB_STEP_SUMMARY |
| 110 | + echo "| Version | \`v$VERSION\` |" >> $GITHUB_STEP_SUMMARY |
| 111 | + echo "| npm | ✅ Published |" >> $GITHUB_STEP_SUMMARY |
| 112 | + echo "| GitHub Release | ✅ Created |" >> $GITHUB_STEP_SUMMARY |
| 113 | + echo "| Database | ✅ Uploaded |" >> $GITHUB_STEP_SUMMARY |
| 114 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 115 | + echo "### 📦 Artifacts" >> $GITHUB_STEP_SUMMARY |
| 116 | + echo "- \`mcmodding-docs.db\` - Documentation index" >> $GITHUB_STEP_SUMMARY |
| 117 | + echo "- \`db-manifest.json\` - Version manifest" >> $GITHUB_STEP_SUMMARY |
| 118 | +
|
| 119 | + # Sync prod back to dev after release |
| 120 | + sync-to-dev: |
| 121 | + name: Sync to Dev |
| 122 | + runs-on: ubuntu-latest |
| 123 | + needs: publish |
| 124 | + if: success() |
| 125 | + |
| 126 | + steps: |
| 127 | + - name: Checkout |
| 128 | + uses: actions/checkout@v4 |
| 129 | + with: |
| 130 | + fetch-depth: 0 |
| 131 | + ref: prod |
| 132 | + |
| 133 | + - name: Configure Git |
| 134 | + run: | |
| 135 | + git config user.name "github-actions[bot]" |
| 136 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 137 | +
|
| 138 | + - name: Create sync PR to dev |
| 139 | + uses: peter-evans/create-pull-request@v5 |
| 140 | + with: |
| 141 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 142 | + commit-message: 'chore: sync prod to dev after release' |
| 143 | + title: 'chore: sync release changes back to dev' |
| 144 | + body: | |
| 145 | + ## 🔄 Post-Release Sync |
| 146 | +
|
| 147 | + This PR syncs the release changes from `prod` back to `dev`: |
| 148 | + - Updated `package.json` version |
| 149 | + - Updated `CHANGELOG.md` |
| 150 | + - Updated `.release-please-manifest.json` |
| 151 | +
|
| 152 | + **Auto-merge recommended** to keep branches in sync. |
| 153 | + branch: sync/prod-to-dev |
| 154 | + base: dev |
| 155 | + delete-branch: true |
| 156 | + labels: 'sync,automated' |
0 commit comments