feat(release): set package version from Git tag in CI workflow
- Added a step in the GitHub Actions workflow to set the package version based on the Git tag during the release process. - This enhancement ensures that the version in package.json reflects the tagged release, improving version management and consistency. This commit streamlines the release process by automating version updates from Git tags.
This commit is contained in:
parent
7aef96de21
commit
2d04b92cac
3 changed files with 43 additions and 2 deletions
19
.github/workflows/release.yml
vendored
19
.github/workflows/release.yml
vendored
|
|
@ -29,6 +29,12 @@ jobs:
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: pnpm install --no-frozen-lockfile
|
run: pnpm install --no-frozen-lockfile
|
||||||
|
|
||||||
|
- name: Set version from tag
|
||||||
|
if: startsWith(github.ref, 'refs/tags/v')
|
||||||
|
run: |
|
||||||
|
VERSION="${GITHUB_REF#refs/tags/v}"
|
||||||
|
pnpm pkg set version="$VERSION"
|
||||||
|
|
||||||
- name: Build app
|
- name: Build app
|
||||||
run: pnpm build
|
run: pnpm build
|
||||||
|
|
||||||
|
|
@ -71,6 +77,12 @@ jobs:
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: pnpm install --no-frozen-lockfile
|
run: pnpm install --no-frozen-lockfile
|
||||||
|
|
||||||
|
- name: Set version from tag
|
||||||
|
if: startsWith(github.ref, 'refs/tags/v')
|
||||||
|
run: |
|
||||||
|
VERSION="${GITHUB_REF#refs/tags/v}"
|
||||||
|
pnpm pkg set version="$VERSION"
|
||||||
|
|
||||||
- name: Package & Release (macOS)
|
- name: Package & Release (macOS)
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
@ -111,6 +123,13 @@ jobs:
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: pnpm install --no-frozen-lockfile
|
run: pnpm install --no-frozen-lockfile
|
||||||
|
|
||||||
|
- name: Set version from tag
|
||||||
|
if: startsWith(github.ref, 'refs/tags/v')
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
VERSION="${GITHUB_REF#refs/tags/v}"
|
||||||
|
pnpm pkg set version="$VERSION"
|
||||||
|
|
||||||
- name: Package & Release (Windows)
|
- name: Package & Release (Windows)
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ import {
|
||||||
} from '@shared/constants';
|
} from '@shared/constants';
|
||||||
import { createLogger } from '@shared/utils/logger';
|
import { createLogger } from '@shared/utils/logger';
|
||||||
import { app, BrowserWindow, ipcMain } from 'electron';
|
import { app, BrowserWindow, ipcMain } from 'electron';
|
||||||
|
import { existsSync } from 'fs';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
|
|
||||||
import { initializeIpcHandlers, removeIpcHandlers } from './ipc/handlers';
|
import { initializeIpcHandlers, removeIpcHandlers } from './ipc/handlers';
|
||||||
|
|
@ -67,6 +68,18 @@ let httpServer: HttpServer;
|
||||||
let fileChangeCleanup: (() => void) | null = null;
|
let fileChangeCleanup: (() => void) | null = null;
|
||||||
let todoChangeCleanup: (() => void) | null = null;
|
let todoChangeCleanup: (() => void) | null = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolve production renderer index path.
|
||||||
|
* Main bundle lives in dist-electron/main, while renderer lives in out/renderer.
|
||||||
|
*/
|
||||||
|
function getRendererIndexPath(): string {
|
||||||
|
const candidates = [
|
||||||
|
join(__dirname, '../../out/renderer/index.html'),
|
||||||
|
join(__dirname, '../renderer/index.html'),
|
||||||
|
];
|
||||||
|
return candidates.find((candidate) => existsSync(candidate)) ?? candidates[0];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wires file watcher events from a ServiceContext to the renderer and HTTP SSE clients.
|
* Wires file watcher events from a ServiceContext to the renderer and HTTP SSE clients.
|
||||||
* Cleans up previous listeners before adding new ones.
|
* Cleans up previous listeners before adding new ones.
|
||||||
|
|
@ -356,7 +369,9 @@ function createWindow(): void {
|
||||||
void mainWindow.loadURL(`http://localhost:${DEV_SERVER_PORT}`);
|
void mainWindow.loadURL(`http://localhost:${DEV_SERVER_PORT}`);
|
||||||
mainWindow.webContents.openDevTools();
|
mainWindow.webContents.openDevTools();
|
||||||
} else {
|
} else {
|
||||||
void mainWindow.loadFile(join(__dirname, '../renderer/index.html'));
|
void mainWindow.loadFile(getRendererIndexPath()).catch((error: unknown) => {
|
||||||
|
logger.error('Failed to load renderer entry HTML:', error);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set traffic light position + notify renderer on first load, and auto-check for updates
|
// Set traffic light position + notify renderer on first load, and auto-check for updates
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import { type HttpServices, registerHttpRoutes } from '@main/http';
|
||||||
import { broadcastEvent } from '@main/http/events';
|
import { broadcastEvent } from '@main/http/events';
|
||||||
import { createLogger } from '@shared/utils/logger';
|
import { createLogger } from '@shared/utils/logger';
|
||||||
import Fastify, { type FastifyInstance } from 'fastify';
|
import Fastify, { type FastifyInstance } from 'fastify';
|
||||||
|
import { existsSync } from 'fs';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
|
|
||||||
const logger = createLogger('Service:HttpServer');
|
const logger = createLogger('Service:HttpServer');
|
||||||
|
|
@ -57,7 +58,13 @@ export class HttpServer {
|
||||||
// Register static file serving (production only)
|
// Register static file serving (production only)
|
||||||
const isDev = process.env.NODE_ENV === 'development';
|
const isDev = process.env.NODE_ENV === 'development';
|
||||||
if (!isDev) {
|
if (!isDev) {
|
||||||
const rendererPath = join(__dirname, '../../renderer');
|
const rendererPathCandidates = [
|
||||||
|
join(__dirname, '../../../out/renderer'),
|
||||||
|
join(__dirname, '../../renderer'),
|
||||||
|
];
|
||||||
|
const rendererPath =
|
||||||
|
rendererPathCandidates.find((candidate) => existsSync(candidate)) ??
|
||||||
|
rendererPathCandidates[0];
|
||||||
await this.app.register(fastifyStatic, {
|
await this.app.register(fastifyStatic, {
|
||||||
root: rendererPath,
|
root: rendererPath,
|
||||||
prefix: '/',
|
prefix: '/',
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue