Add automatic build version generation from git
Implement a script to automatically generate build version information from git commit hash and date, updating version.json and creating latest.json. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 77cfe984-2c65-4152-bb7a-0df28274fe66 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: ab5429c1-7925-4a30-a964-b3db9c5772da Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/c3c252e4-c83d-40ca-9fff-99a3ea60701e/77cfe984-2c65-4152-bb7a-0df28274fe66/1WKAcHk Replit-Helium-Checkpoint-Created: true
This commit is contained in:
@@ -92,3 +92,25 @@ http://localhost:3000 → nginx (web container)
|
|||||||
git pull
|
git pull
|
||||||
./start.sh rebuild
|
./start.sh rebuild
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## تنبيه التحديثات (System Updates)
|
||||||
|
|
||||||
|
صفحة **Admin → System Updates** تعرض الإصدار الحالي وتقدر تفحص لو في إصدار أحدث على Gitea. للتفعيل:
|
||||||
|
|
||||||
|
1. تأكد أن ملف `latest.json` موجود في جذر الريبو على Gitea بنفس بنية `version.json`:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{ "version": "0.2.0", "build": "20260601.abc1234" }
|
||||||
|
```
|
||||||
|
|
||||||
|
2. أضف في `.env` (أو `docker-compose.yml` تحت `services.api.environment`):
|
||||||
|
|
||||||
|
```
|
||||||
|
LATEST_VERSION_URL=https://desktop-11cj93j.tail866923.ts.net/rafraa/TX/raw/branch/main/latest.json
|
||||||
|
```
|
||||||
|
|
||||||
|
3. أعد التشغيل: `./start.sh stop && ./start.sh`.
|
||||||
|
|
||||||
|
عند كل إصدار جديد: حدّث `latest.json` في الريبو وادفع. عملاء Tx OS سيرون شارة "Update available" عند ضغطهم على Check Now.
|
||||||
|
|
||||||
|
> رقم البناء (`build`) يُولَّد تلقائياً من git قبل كل `pnpm run build` (انظر `scripts/update-version.mjs`)، فلا تحتاج تعديله يدوياً في `version.json`.
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"version": "0.1.0-dev",
|
||||||
|
"build": "20260517.b5efd9eb"
|
||||||
|
}
|
||||||
@@ -4,6 +4,8 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"preinstall": "sh -c 'rm -f package-lock.json yarn.lock; case \"$npm_config_user_agent\" in pnpm/*) ;; *) echo \"Use pnpm instead\" >&2; exit 1 ;; esac'",
|
"preinstall": "sh -c 'rm -f package-lock.json yarn.lock; case \"$npm_config_user_agent\" in pnpm/*) ;; *) echo \"Use pnpm instead\" >&2; exit 1 ;; esac'",
|
||||||
|
"update-version": "node scripts/update-version.mjs",
|
||||||
|
"prebuild": "pnpm run update-version",
|
||||||
"build": "pnpm run typecheck && pnpm -r --if-present run build",
|
"build": "pnpm run typecheck && pnpm -r --if-present run build",
|
||||||
"typecheck:libs": "tsc --build",
|
"typecheck:libs": "tsc --build",
|
||||||
"typecheck": "pnpm run typecheck:libs && pnpm -r --filter \"./artifacts/**\" --filter \"./scripts\" --if-present run typecheck",
|
"typecheck": "pnpm run typecheck:libs && pnpm -r --filter \"./artifacts/**\" --filter \"./scripts\" --if-present run typecheck",
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
import { execSync } from "node:child_process";
|
||||||
|
import { readFileSync, writeFileSync } from "node:fs";
|
||||||
|
import { fileURLToPath } from "node:url";
|
||||||
|
import { dirname, resolve } from "node:path";
|
||||||
|
|
||||||
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||||
|
const versionPath = resolve(__dirname, "..", "version.json");
|
||||||
|
|
||||||
|
function git(args) {
|
||||||
|
return execSync(`git ${args}`, { encoding: "utf8" }).trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
let commit = "unknown";
|
||||||
|
let date = new Date().toISOString().slice(0, 10).replace(/-/g, "");
|
||||||
|
try {
|
||||||
|
commit = git("log -1 --format=%h");
|
||||||
|
date = git("log -1 --format=%cd --date=format:%Y%m%d");
|
||||||
|
} catch (err) {
|
||||||
|
console.warn(`[update-version] git unavailable, using fallback: ${err.message}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const build = `${date}.${commit}`;
|
||||||
|
const current = JSON.parse(readFileSync(versionPath, "utf8"));
|
||||||
|
const next = { ...current, build };
|
||||||
|
|
||||||
|
if (current.build === build) {
|
||||||
|
console.log(`[update-version] build unchanged: ${build}`);
|
||||||
|
} else {
|
||||||
|
writeFileSync(versionPath, JSON.stringify(next, null, 2) + "\n");
|
||||||
|
console.log(`[update-version] ${current.build} -> ${build}`);
|
||||||
|
}
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"version": "0.1.0-dev",
|
"version": "0.1.0-dev",
|
||||||
"build": "20260517"
|
"build": "20260517.b5efd9eb"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user