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