Skip to content

Build your personal knowledge base with Trilium Notes

feat(ci): check version consistency before releasing

Elian Doran0b25b09040b6
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 28d45245d0..7d893979af 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -11,6 +11,14 @@ concurrency:
cancel-in-progress: true
jobs:
+ sanity-check:
+ name: Sanity Check
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v6
+
+ - name: Check version consistency
+ run: pnpm tsx ${{ github.workspace }}/scripts/check-version-consistency.ts ${{ github.ref_name }}
make-electron:
name: Make Electron
strategy:
diff --git a/scripts/check-version-consistency.ts b/scripts/check-version-consistency.ts
new file mode 100644
index 0000000000..235167b2d5
--- /dev/null
+++ b/scripts/check-version-consistency.ts
@@ -0,0 +1,33 @@
+import { readFileSync } from "fs";
+import { join } from "path";
+
+const projectRoot = join(__dirname, '..');
+const filesToCheck = [
+ 'package.json',
+ 'apps/server/package.json',
+ 'apps/client/package.json',
+ 'apps/desktop/package.json',
+ 'packages/commons/package.json',
+]
+
+function main() {
+ const expectedVersion = process.argv[2];
+ if (!expectedVersion) {
+ console.error('Expected version argument is missing.');
+ process.exit(1);
+ }
+
+ for (const fileToCheck of filesToCheck) {
+ const packageJsonPath = join(projectRoot, fileToCheck);
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
+ const version = packageJson.version;
+ if (version !== expectedVersion) {
+ console.error(`Version mismatch in ${fileToCheck}: expected ${expectedVersion}, found ${version}`);
+ process.exit(1);
+ }
+ }
+
+ console.log('All versions are consistent:', expectedVersion);
+}
+
+main();