Skip to content

Commit c5a8a94

Browse files
author
ogmatrix
committed
feat: improved versioning and managing and made db version independent
1 parent 214a308 commit c5a8a94

12 files changed

Lines changed: 235 additions & 128 deletions

.github/workflows/release.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,15 @@ jobs:
7575
env:
7676
RELEASE_TAG: ${{ github.event.release.tag_name }}
7777
run: |
78-
VERSION=${RELEASE_TAG#v}
79-
echo "Generating manifest for version $VERSION"
78+
echo "Generating new database manifest version..."
8079
81-
# Regenerate manifest to ensure it matches the release version
82-
npm run db:manifest -- --version "$VERSION" --changelog "Release $RELEASE_TAG"
80+
# Regenerate manifest with a patch bump to ensure a new version is created
81+
# This makes the DB version independent of the package version
82+
npm run db:manifest -- --bump patch --changelog "Release $RELEASE_TAG" --release-tag "$RELEASE_TAG"
83+
84+
# Log the new DB version
85+
DB_VERSION=$(node -p "require('./data/db-manifest.json').version")
86+
echo "Generated DB Manifest Version: $DB_VERSION"
8387
8488
mkdir -p release-artifacts
8589
cp data/mcmodding-docs.db release-artifacts/

.github/workflows/update-docs-weekly.yml

Lines changed: 44 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Weekly Documentation Update
22

33
on:
44
schedule:
5-
# Run every Sunday at 2:00 UTC (only changed pages, minimal update)
5+
# Run every Sunday at 2:00 UTC
66
- cron: '0 2 * * 0'
77
workflow_dispatch: # Allow manual trigger
88

@@ -14,13 +14,13 @@ jobs:
1414
update-docs:
1515
name: Update Documentation Index
1616
runs-on: ubuntu-latest
17-
timeout-minutes: 60
17+
timeout-minutes: 120 # Increased timeout for full re-index
1818

1919
steps:
2020
- name: Checkout code
2121
uses: actions/checkout@v4
2222
with:
23-
ref: prod
23+
ref: dev # Checkout dev branch to commit changes later
2424
fetch-depth: 0
2525
lfs: true
2626

@@ -43,83 +43,58 @@ jobs:
4343
- name: Install dependencies
4444
run: npm ci
4545

46-
- name: Update documentation (incremental, with embeddings)
47-
run: npm run index-docs -- --incremental --sitemap --embeddings
46+
- name: Get Latest Release Tag
47+
id: get_release
4848
env:
49-
# Allow longer timeout for embedding generation
50-
NODE_OPTIONS: --max-old-space-size=6144
49+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
run: |
51+
LATEST_TAG=$(gh release list --limit 1 --json tagName --jq '.[0].tagName')
52+
echo "Latest release tag: $LATEST_TAG"
53+
echo "tag=$LATEST_TAG" >> $GITHUB_OUTPUT
5154
52-
- name: Check for changes
53-
id: check_changes
55+
- name: Re-index Documentation (Full Rebuild)
5456
run: |
55-
if git diff --quiet data/mcmodding-docs.db 2>/dev/null; then
56-
echo "has_changes=false" >> $GITHUB_OUTPUT
57-
echo "No documentation changes detected"
58-
else
59-
echo "has_changes=true" >> $GITHUB_OUTPUT
60-
echo "Documentation changes detected"
61-
fi
57+
# Remove existing database to ensure a fresh index
58+
rm -f data/mcmodding-docs.db
59+
60+
# Run full index (no incremental flag)
61+
npm run index-docs -- --sitemap --embeddings
62+
env:
63+
# Allow longer timeout and more memory for embedding generation
64+
NODE_OPTIONS: --max-old-space-size=8192
6265

63-
- name: Generate database manifest (incremental)
64-
if: steps.check_changes.outputs.has_changes == 'true'
66+
- name: Generate New Database Manifest
6567
run: |
66-
TIMESTAMP=$(date -u +'%Y.%m.%d')
67-
npm run db:manifest -- --version "$TIMESTAMP" --type incremental --changelog "Incremental weekly documentation update"
68+
# Generate manifest with a patch bump
69+
npm run db:manifest -- --bump patch --changelog "Weekly update for $LATEST_TAG" --release-tag "$LATEST_TAG"
70+
env:
71+
LATEST_TAG: ${{ steps.get_release.outputs.tag }}
6872

69-
- name: Commit documentation updates
70-
if: steps.check_changes.outputs.has_changes == 'true'
73+
- name: Update Release Assets
74+
env:
75+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
76+
TAG: ${{ steps.get_release.outputs.tag }}
7177
run: |
72-
git add data/mcmodding-docs.db data/db-manifest.json
73-
git commit -m "fix(docs): update documentation index" -m "- Incremental update of documentation pages
74-
- Updated embeddings for semantic search
75-
- Automated weekly update
78+
echo "Uploading new database assets to release $TAG..."
79+
gh release upload "$TAG" data/mcmodding-docs.db data/db-manifest.json --clobber
7680
77-
Generated by: GitHub Actions (update-docs-weekly)"
81+
- name: Commit and Push to Dev
82+
run: |
83+
git add data/mcmodding-docs.db data/db-manifest.json
7884
79-
- name: Create Pull Request
80-
if: steps.check_changes.outputs.has_changes == 'true'
81-
uses: peter-evans/create-pull-request@v5
82-
with:
83-
commit-message: 'fix(docs): update documentation index'
84-
title: 'fix(docs): weekly documentation update'
85-
body: |
86-
## Weekly Documentation Update
87-
88-
This PR updates the documentation index with the latest content from:
89-
- wiki.fabricmc.net
90-
- docs.fabricmc.net
91-
92-
### Changes
93-
- ✅ Fetched latest documentation pages
94-
- ✅ Updated chunks for incremental changes only
95-
- ✅ Regenerated semantic embeddings for updated chunks
96-
- ✅ Database stored via Git LFS
97-
- ✅ No breaking changes
98-
99-
### How to Test
100-
```bash
101-
npm run start
102-
```
103-
104-
Then test the `search_fabric_docs` and `explain_fabric_concept` tools with recent topics.
105-
106-
---
107-
*This is an automated weekly update. No manual action needed.*
108-
branch: 'docs/update-${{ github.run_number }}'
109-
base: prod
110-
delete-branch: true
111-
labels: 'documentation,automated'
85+
# Check if there are changes to commit
86+
if git diff --staged --quiet; then
87+
echo "No changes to commit"
88+
else
89+
git commit -m "weekly documentation update [skip ci]"
90+
git push origin dev
91+
fi
11292
11393
- name: Log summary
94+
if: always()
11495
run: |
11596
echo "## Documentation Update Summary" >> $GITHUB_STEP_SUMMARY
11697
echo "" >> $GITHUB_STEP_SUMMARY
117-
if [[ "${{ steps.check_changes.outputs.has_changes }}" == "true" ]]; then
118-
echo "✅ Documentation index updated with incremental changes" >> $GITHUB_STEP_SUMMARY
119-
else
120-
echo "ℹ️ No documentation changes detected" >> $GITHUB_STEP_SUMMARY
121-
fi
122-
echo "" >> $GITHUB_STEP_SUMMARY
123-
echo "**Schedule:** Every Sunday at 2:00 UTC" >> $GITHUB_STEP_SUMMARY
124-
echo "**Update Type:** Incremental (only changed pages)" >> $GITHUB_STEP_SUMMARY
125-
echo "**Embeddings:** Regenerated for changed chunks" >> $GITHUB_STEP_SUMMARY
98+
echo "✅ Full re-index completed" >> $GITHUB_STEP_SUMMARY
99+
echo "✅ Database assets updated in release ${{ steps.get_release.outputs.tag }}" >> $GITHUB_STEP_SUMMARY
100+
echo "✅ Changes committed to dev branch" >> $GITHUB_STEP_SUMMARY

data/db-manifest.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"version": "0.2.2",
3-
"timestamp": "2025-12-17T22:09:19.559Z",
3+
"timestamp": "2025-12-20T16:28:52.918Z",
44
"type": "incremental",
55
"hash": "30eabb7295d5824e30c7cd623ac77e453973dfa7923e5d349dd36fa6edbfba57",
66
"size": 579399680,
77
"downloadUrl": "https://github.com/OGMatrix/mcmodding-mcp/releases/download/v0.2.2/mcmodding-docs.db",
8-
"changelog": "Release v0.2.2"
9-
}
8+
"changelog": "Updated documentation index"
9+
}

data/mod-examples-manifest.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"version": "0.1.1",
3-
"timestamp": "2025-12-16T17:44:59.537Z",
4-
"hash": "63d5f2cf0c3b4de1b183af3f567eb8931e71b64a06888af8b971a3747da441b7",
5-
"size": 172032,
6-
"downloadUrl": "https://github.com/OGMatrix/mcmodding-mcp/releases/download/examples-v0.1.1/mod-examples.db",
2+
"version": "0.2.0",
3+
"timestamp": "2025-12-20T16:28:58.319Z",
4+
"hash": "bf642eee9e8293f52be5b61d3e94790f16be6a837d81b69cd4a3c93adf305732",
5+
"size": 200704,
6+
"downloadUrl": "https://github.com/OGMatrix/mcmodding-mcp/releases/download/examples-v0.2.0/mod-examples.db",
77
"stats": {
88
"mods": 1,
99
"examples": 3,

data/mod-examples.db-shm

0 Bytes
Binary file not shown.

scripts/generate-db-manifest.ts

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,68 @@ import { DbVersioning } from '../src/db-versioning.js';
88
import fs from 'fs';
99
import path from 'path';
1010

11+
function bumpVersion(version: string, type: string): string {
12+
const parts = version.split('.').map(Number);
13+
if (parts.length !== 3 || parts.some(isNaN)) {
14+
console.warn(`Warning: Could not parse version ${version}, defaulting to 0.1.0`);
15+
return '0.1.0';
16+
}
17+
18+
let [major, minor, patch] = parts;
19+
20+
switch (type.toLowerCase()) {
21+
case 'major':
22+
major++;
23+
minor = 0;
24+
patch = 0;
25+
break;
26+
case 'minor':
27+
minor++;
28+
patch = 0;
29+
break;
30+
case 'patch':
31+
patch++;
32+
break;
33+
default:
34+
console.warn(`Warning: Unknown bump type ${type}, using patch`);
35+
patch++;
36+
}
37+
38+
return `${major}.${minor}.${patch}`;
39+
}
40+
1141
async function main() {
1242
const args = process.argv.slice(2);
43+
const versioning = new DbVersioning();
44+
const localManifest = versioning.getLocalManifest();
1345

14-
// Parse arguments
15-
const packageJson = JSON.parse(
16-
fs.readFileSync(path.join(process.cwd(), 'package.json'), 'utf-8')
17-
);
18-
let version = packageJson.version;
46+
// Default to existing manifest version or 0.1.0 if not found
47+
// This ensures DB version is independent of package.json version
48+
let version = localManifest?.version || '0.1.0';
1949
let type: 'incremental' | 'full' = 'incremental';
2050
let changelog = 'Updated documentation index';
51+
let releaseTag = '';
2152

2253
for (let i = 0; i < args.length; i++) {
2354
if (args[i] === '--version' && args[i + 1]) {
2455
version = args[++i];
56+
} else if (args[i] === '--bump' && args[i + 1]) {
57+
const bumpType = args[++i];
58+
const oldVersion = version;
59+
version = bumpVersion(version, bumpType);
60+
console.log(`Bumped version: ${oldVersion} -> ${version} (${bumpType})`);
2561
} else if (args[i] === '--type' && args[i + 1]) {
2662
type = args[++i] as 'incremental' | 'full';
2763
} else if (args[i] === '--changelog' && args[i + 1]) {
2864
changelog = args[++i];
65+
} else if (args[i] === '--release-tag' && args[i + 1]) {
66+
releaseTag = args[++i];
2967
}
3068
}
3169

32-
const versioning = new DbVersioning();
33-
3470
try {
3571
console.log('📋 Generating database manifest...');
36-
const manifest = await versioning.createManifest(version, type, changelog);
72+
const manifest = await versioning.createManifest(version, type, changelog, releaseTag);
3773

3874
console.log(`\n✅ Manifest created successfully:`);
3975
console.log(` Version: ${manifest.version}`);

scripts/generate-mod-examples-manifest.ts

Lines changed: 59 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,36 @@ function log(level: 'info' | 'warn' | 'error' | 'success', message: string): voi
8686
method(`${colors[level]}${icons[level]} ${message}${reset}`);
8787
}
8888

89+
function bumpVersion(version: string, type: string): string {
90+
const parts = version.split('.').map(Number);
91+
if (parts.length !== 3 || parts.some(isNaN)) {
92+
log('warn', `Warning: Could not parse version ${version}, defaulting to 0.1.0`);
93+
return '0.1.0';
94+
}
95+
96+
let [major, minor, patch] = parts;
97+
98+
switch (type.toLowerCase()) {
99+
case 'major':
100+
major++;
101+
minor = 0;
102+
patch = 0;
103+
break;
104+
case 'minor':
105+
minor++;
106+
patch = 0;
107+
break;
108+
case 'patch':
109+
patch++;
110+
break;
111+
default:
112+
log('warn', `Warning: Unknown bump type ${type}, using patch`);
113+
patch++;
114+
}
115+
116+
return `${major}.${minor}.${patch}`;
117+
}
118+
89119
// ═══════════════════════════════════════════════════════════════════════════════
90120
// MAIN LOGIC
91121
// ═══════════════════════════════════════════════════════════════════════════════
@@ -99,14 +129,35 @@ async function generateManifest(): Promise<void> {
99129

100130
// Parse command line arguments
101131
const args = process.argv.slice(2);
102-
const packageJson = JSON.parse(
103-
fs.readFileSync(path.join(process.cwd(), 'package.json'), 'utf-8')
104-
);
105-
const version =
106-
args.find((a) => a.startsWith('--version='))?.split('=')[1] || packageJson.version;
132+
133+
// Read existing manifest if available
134+
let existingVersion = '0.1.0';
135+
try {
136+
if (fs.existsSync(CONFIG.manifestPath)) {
137+
const existingManifest = JSON.parse(fs.readFileSync(CONFIG.manifestPath, 'utf-8')) as {
138+
version: string;
139+
};
140+
existingVersion = existingManifest.version;
141+
}
142+
} catch {
143+
// ignore
144+
}
145+
146+
let version = args.find((a) => a.startsWith('--version='))?.split('=')[1] || existingVersion;
147+
148+
const bumpArg = args.find((a) => a.startsWith('--bump='));
149+
if (bumpArg) {
150+
const bumpType = bumpArg.split('=')[1];
151+
const oldVersion = version;
152+
version = bumpVersion(version, bumpType);
153+
log('info', `Bumped version: ${oldVersion} -> ${version} (${bumpType})`);
154+
}
155+
107156
const changelog =
108157
args.find((a) => a.startsWith('--changelog='))?.split('=')[1] || 'Mod examples update';
109158

159+
const releaseTag = args.find((a) => a.startsWith('--release-tag='))?.split('=')[1];
160+
110161
// Check database exists
111162
if (!fs.existsSync(CONFIG.dbPath)) {
112163
log('error', `Database not found: ${CONFIG.dbPath}`);
@@ -224,7 +275,9 @@ async function generateManifest(): Promise<void> {
224275
timestamp: new Date().toISOString(),
225276
hash,
226277
size: stats.size,
227-
downloadUrl: CONFIG.downloadUrlTemplate.replace('{version}', version),
278+
downloadUrl: releaseTag
279+
? `https://github.com/OGMatrix/mcmodding-mcp/releases/download/${releaseTag}/mod-examples.db`
280+
: CONFIG.downloadUrlTemplate.replace('{version}', version),
228281
stats: {
229282
mods: basicStats.mods,
230283
examples: basicStats.examples,

scripts/postinstall.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env node
2+
/* eslint-disable no-undef, no-control-regex, no-unused-vars */
23

34
/**
45
* MCModding-MCP Postinstall Script
@@ -735,6 +736,13 @@ async function main() {
735736
if (!manifestAsset) throw new Error('No manifest found in release');
736737

737738
manifest = await fetchManifest(manifestAsset.browser_download_url);
739+
740+
// Find the database asset in the release to ensure we have the correct download URL
741+
// This overrides the URL in the manifest which might be outdated or incorrect
742+
const dbAsset = release.assets.find((a) => a.name === CONFIG.dbFileName);
743+
if (dbAsset) {
744+
manifest.downloadUrl = dbAsset.browser_download_url;
745+
}
738746
} catch (error) {
739747
process.stdout.write(c.cursorUp + c.clearLine);
740748
printStepIndicator(2, 4, `Failed to fetch release info: ${error.message}`, 'error');

scripts/update-version.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable no-undef */
12
import fs from 'fs';
23
import path from 'path';
34
import { fileURLToPath } from 'url';

0 commit comments

Comments
 (0)