mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-11 15:16:28 +08:00
build(electron): allow customizing channel type for internal build (#4511)
This commit is contained in:
@@ -2,6 +2,15 @@ name: Build Canary Desktop App on Staging Branch
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
channel_override:
|
||||
description: 'channel type (canary, beta, or stable)'
|
||||
type: choice
|
||||
default: beta
|
||||
options:
|
||||
- canary
|
||||
- beta
|
||||
- stable
|
||||
push:
|
||||
branches:
|
||||
# 0.6.x-staging
|
||||
@@ -27,7 +36,10 @@ concurrency:
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
# BUILD_TYPE => app icon, app name, etc
|
||||
BUILD_TYPE: internal
|
||||
# BUILD_TYPE_OVERRIDE => channel type (canary, beta, or stable) - get the channel type (the api configs)
|
||||
BUILD_TYPE_OVERRIDE: ${{ github.event.inputs.channel_override || 'beta' }}
|
||||
|
||||
jobs:
|
||||
set-build-version:
|
||||
|
||||
@@ -15,12 +15,21 @@ if (process.platform === 'win32') {
|
||||
|
||||
async function buildLayers() {
|
||||
const common = config();
|
||||
|
||||
const define = {
|
||||
'process.env.NODE_ENV': `"${NODE_ENV}"`,
|
||||
'process.env.BUILD_TYPE': `"${process.env.BUILD_TYPE || 'stable'}"`,
|
||||
};
|
||||
|
||||
if (process.env.BUILD_TYPE_OVERRIDE) {
|
||||
define[
|
||||
'process.env.BUILD_TYPE_OVERRIDE'
|
||||
] = `"${process.env.BUILD_TYPE_OVERRIDE}"`;
|
||||
}
|
||||
|
||||
await esbuild.build({
|
||||
...common.layers,
|
||||
define: {
|
||||
'process.env.NODE_ENV': `"${NODE_ENV}"`,
|
||||
'process.env.BUILD_TYPE': `"${process.env.BUILD_TYPE || 'stable'}"`,
|
||||
},
|
||||
define: define,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,8 @@ if (!process.env.SKIP_WEB_BUILD) {
|
||||
await $`yarn -T run build:plugins`;
|
||||
await $`yarn nx build @affine/core`;
|
||||
|
||||
await $`yarn workspace @affine/electron build`;
|
||||
|
||||
// step 1.5: amend sourceMappingURL to allow debugging in devtools
|
||||
await glob('**/*.{js,css}', { cwd: affineCoreOutDir }).then(files => {
|
||||
return files.map(async file => {
|
||||
|
||||
@@ -7,9 +7,16 @@ export const ReleaseTypeSchema = z.enum([
|
||||
'internal',
|
||||
]);
|
||||
|
||||
export const envBuildType = (process.env.BUILD_TYPE || 'canary')
|
||||
export const envBuildType = (
|
||||
process.env.BUILD_TYPE_OVERRIDE ||
|
||||
process.env.BUILD_TYPE ||
|
||||
'canary'
|
||||
)
|
||||
.trim()
|
||||
.toLowerCase();
|
||||
|
||||
export const overrideSession = process.env.BUILD_TYPE === 'internal';
|
||||
|
||||
export const buildType = ReleaseTypeSchema.parse(envBuildType);
|
||||
|
||||
export const mode = process.env.NODE_ENV;
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import './security-restrictions';
|
||||
|
||||
import path from 'node:path';
|
||||
|
||||
import { app } from 'electron';
|
||||
|
||||
import { createApplicationMenu } from './application-menu/create';
|
||||
import { buildType, overrideSession } from './config';
|
||||
import { setupDeepLink } from './deep-link';
|
||||
import { registerEvents } from './events';
|
||||
import { registerHandlers } from './handlers';
|
||||
@@ -14,6 +17,14 @@ import { registerUpdater } from './updater';
|
||||
|
||||
app.enableSandbox();
|
||||
|
||||
// use the same data for internal & beta for testing
|
||||
if (overrideSession) {
|
||||
const appName = buildType === 'stable' ? 'AFFiNE' : `AFFiNE-${buildType}`;
|
||||
const userDataPath = path.join(app.getPath('appData'), appName);
|
||||
app.setPath('userData', userDataPath);
|
||||
app.setPath('sessionData', userDataPath);
|
||||
}
|
||||
|
||||
if (require('electron-squirrel-startup')) app.quit();
|
||||
// allow tests to overwrite app name through passing args
|
||||
if (process.argv.includes('--app-name')) {
|
||||
|
||||
@@ -1,23 +1,12 @@
|
||||
import { app } from 'electron';
|
||||
import { autoUpdater } from 'electron-updater';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { isMacOS, isWindows } from '../../shared/utils';
|
||||
import { buildType } from '../config';
|
||||
import { logger } from '../logger';
|
||||
import { CustomGitHubProvider } from './custom-github-provider';
|
||||
import { updaterSubjects } from './event';
|
||||
|
||||
export const ReleaseTypeSchema = z.enum([
|
||||
'stable',
|
||||
'beta',
|
||||
'canary',
|
||||
'internal',
|
||||
]);
|
||||
|
||||
export const envBuildType = (process.env.BUILD_TYPE || 'canary')
|
||||
.trim()
|
||||
.toLowerCase();
|
||||
export const buildType = ReleaseTypeSchema.parse(envBuildType);
|
||||
const mode = process.env.NODE_ENV;
|
||||
const isDev = mode === 'development';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user