add automatic app version and park git init tag from vojo/dev

This commit is contained in:
v.lagerev 2026-04-20 22:58:38 +03:00
parent dabe5ca4b8
commit 2c1063f4c9
8 changed files with 38 additions and 5426 deletions

View file

@ -21,14 +21,6 @@ jobs:
package-manager-cache: false
- name: Install dependencies
run: npm ci
- name: Run semantic release
run: npm run semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }}
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
GIT_COMMITTER_NAME: ${{ secrets.GIT_AUTHOR_NAME }}
GIT_COMMITTER_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
- name: Get version from tag
id: vars
run: |

5348
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -25,8 +25,7 @@
"build:android:release": "npm run build && npm run android:sync && npm run android:apk:release",
"build:android:aab": "npm run build && npm run android:sync && npm run android:aab:release",
"prepare": "husky install",
"commit": "git-cz",
"semantic-release": "semantic-release"
"commit": "git-cz"
},
"lint-staged": {
"*.{ts,tsx,js,jsx}": "eslint",
@ -37,35 +36,6 @@
"path": "./node_modules/cz-conventional-changelog"
}
},
"release": {
"branches": [
"dev"
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
[
"@semantic-release/exec",
{
"prepareCmd": "node scripts/update-version.js ${nextRelease.version}"
}
],
[
"@semantic-release/git",
{
"assets": [
"package.json",
"package-lock.json",
"src/app/features/settings/about/About.tsx",
"src/app/pages/auth/AuthFooter.tsx",
"src/app/pages/client/WelcomePage.tsx"
],
"message": "chore(release): ${nextRelease.version} [skip ci]"
}
],
"@semantic-release/github"
]
},
"keywords": [],
"author": "Ajay Bura",
"license": "AGPL-3.0-only",
@ -139,8 +109,6 @@
"@esbuild-plugins/node-globals-polyfill": "0.2.3",
"@rollup/plugin-inject": "5.0.3",
"@rollup/plugin-wasm": "6.1.1",
"@semantic-release/exec": "7.1.0",
"@semantic-release/git": "10.0.1",
"@types/chroma-js": "3.1.1",
"@types/file-saver": "2.0.5",
"@types/is-hotkey": "0.1.10",
@ -166,7 +134,6 @@
"husky": "9.1.7",
"lint-staged": "16.3.2",
"prettier": "2.8.1",
"semantic-release": "25.0.3",
"typescript": "4.9.4",
"vite": "5.4.19",
"vite-plugin-pwa": "0.20.5",

View file

@ -1,48 +0,0 @@
import fs from "fs";
import path from "path";
import { execSync } from "child_process";
import { fileURLToPath } from "url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const version = process.argv[2];
if (!version) {
console.error("Version argument missing");
process.exit(1);
}
const root = path.resolve(__dirname, "..");
const newVersionTag = `v${version}`;
// Update package.json + package-lock.json safely
execSync(`npm version ${version} --no-git-tag-version`, {
cwd: root,
stdio: "inherit",
});
console.log(`Updated package.json and package-lock.json → ${version}`);
// Update UI version references
const files = [
"src/app/features/settings/about/About.tsx",
"src/app/pages/auth/AuthFooter.tsx",
"src/app/pages/client/WelcomePage.tsx",
];
files.forEach((filePath) => {
const absPath = path.join(root, filePath);
if (!fs.existsSync(absPath)) {
console.warn(`File not found: ${filePath}`);
return;
}
const content = fs.readFileSync(absPath, "utf8");
const updated = content.replace(/v\d+\.\d+\.\d+/g, newVersionTag);
fs.writeFileSync(absPath, updated);
console.log(`Updated ${filePath}${newVersionTag}`);
});

View file

@ -48,7 +48,7 @@ export function About({ requestClose }: AboutProps) {
<Box direction="Column" gap="100">
<Box gap="100" alignItems="End">
<Text size="H3">Vojo</Text>
<Text size="T200">v4.11.1</Text>
<Text size="T200">{__APP_VERSION__}</Text>
</Box>
<Text>{t('Settings.about_tagline')}</Text>
</Box>

View file

@ -16,7 +16,7 @@ export function WelcomePage() {
<PageHero
icon={<img width="70" height="70" src={VojoSVG} alt="Vojo Logo" />}
title="Welcome to Vojo"
subTitle={<span>v4.11.1</span>}
subTitle={<span>{__APP_VERSION__}</span>}
/>
</PageHeroSection>
</Box>

2
src/ext.d.ts vendored
View file

@ -1,5 +1,7 @@
/// <reference types="vite/client" />
declare const __APP_VERSION__: string;
declare module 'browser-encrypt-attachment' {
export interface EncryptedAttachmentInfo {
v: string;

View file

@ -9,8 +9,24 @@ import topLevelAwait from 'vite-plugin-top-level-await';
import { VitePWA } from 'vite-plugin-pwa';
import fs from 'fs';
import path from 'path';
import { execSync } from 'child_process';
import buildConfig from './build.config';
function resolveAppVersion() {
if (process.env.VITE_APP_VERSION) return process.env.VITE_APP_VERSION;
try {
return execSync('git describe --tags --always --dirty', {
stdio: ['ignore', 'pipe', 'ignore'],
})
.toString()
.trim();
} catch {
// Fallback for builds without a usable .git (e.g. Docker — .git is in .dockerignore)
const pkg = JSON.parse(fs.readFileSync(path.resolve('package.json'), 'utf8'));
return `v${pkg.version}`;
}
}
const copyFiles = {
targets: [
{
@ -82,6 +98,9 @@ export default defineConfig({
appType: 'spa',
publicDir: false,
base: buildConfig.base,
define: {
__APP_VERSION__: JSON.stringify(resolveAppVersion()),
},
server: {
port: 8080,
host: true,