build: add canary build (#1986)

Co-authored-by: Himself65 <himself65@outlook.com>
Co-authored-by: Horus <lhlxtl@gmail.com>
This commit is contained in:
Peng Xiao 2023-04-18 00:32:10 +08:00 committed by GitHub
parent 54a30bbf20
commit 11de3a681f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 100 additions and 65 deletions

View File

@ -17,6 +17,11 @@ on:
type: boolean
required: true
default: true
is-canary:
description: 'Canary Release? The app will be named as "AFFiNE Canary"'
type: boolean
required: true
default: true
permissions:
actions: write
@ -29,9 +34,12 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true
env:
BUILD_TYPE: ${{ github.event.inputs.is-canary == 'true' && 'canary' || 'stable' }}
jobs:
make-macos:
environment: production
environment: ${{ github.ref_name == 'master' && 'production' || 'development' }}
env:
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
@ -62,19 +70,6 @@ jobs:
with:
electron-workspace-install: true
- name: install Rust stable
uses: dtolnay/rust-toolchain@stable
- name: add arm64 target
if: matrix.arch == 'arm64'
run: rustup target add aarch64-apple-darwin
- name: Rust cache
uses: swatinem/rust-cache@v2
with:
key: ${{ matrix.arch }}
workspaces: './packages/octobase-node -> target'
- name: Signing By Apple Developer ID
uses: apple-actions/import-codesign-certs@v2
with:
@ -88,7 +83,7 @@ jobs:
- name: Save artifacts
run: |
mkdir -p builds
mv apps/electron/out/make/AFFiNE.dmg ./builds/affine-darwin-${{ matrix.arch }}.dmg
mv apps/electron/out/*/make/*.dmg ./builds/affine-${{ env.BUILD_TYPE }}-darwin-${{ matrix.arch }}.dmg
- name: Upload Artifact
uses: actions/upload-artifact@v3
@ -98,11 +93,8 @@ jobs:
make-windows:
runs-on: windows-latest
environment: production
environment: ${{ github.ref_name == 'master' && 'production' || 'development' }}
env:
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
NEXT_PUBLIC_FIREBASE_API_KEY: ${{ secrets.NEXT_PUBLIC_FIREBASE_API_KEY }}
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN: ${{ secrets.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN }}
NEXT_PUBLIC_FIREBASE_PROJECT_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_PROJECT_ID }}
@ -125,14 +117,6 @@ jobs:
with:
electron-workspace-install: true
- name: install Rust stable
uses: dtolnay/rust-toolchain@stable
- name: Rust cache
uses: swatinem/rust-cache@v2
with:
workspaces: './packages/octobase-node -> target'
- name: make build
run: yarn make-windows-x64
working-directory: apps/electron
@ -140,19 +124,60 @@ jobs:
- name: Save windows artifacts
run: |
mkdir -p builds
mv apps/electron/out/make/zip/win32/x64/AFFiNE-win32-x64-*.zip ./builds/affine-windows-x64.zip
mv apps/electron/out/make/squirrel.windows/x64/*.exe ./builds/affine-windows-x64.exe
mv apps/electron/out/make/squirrel.windows/x64/*.msi ./builds/affine-windows-x64.msi
mv apps/electron/out/make/squirrel.windows/x64/*.nupkg ./builds/affine-windows-x64.nupkg
mv apps/electron/out/make/squirrel.windows/x64/RELEASES ./builds/RELEASES
mv apps/electron/out/*/make/zip/win32/x64/AFFiNE*-win32-x64-*.zip ./builds/affine-${{ env.BUILD_TYPE }}-windows-x64.zip
mv apps/electron/out/*/make/squirrel.windows/x64/*.exe ./builds/affine-${{ env.BUILD_TYPE }}-windows-x64.exe
mv apps/electron/out/*/make/squirrel.windows/x64/*.msi ./builds/affine-${{ env.BUILD_TYPE }}-windows-x64.msi
mv apps/electron/out/*/make/squirrel.windows/x64/*.nupkg ./builds/affine-${{ env.BUILD_TYPE }}-windows-x64.nupkg
mv apps/electron/out/*/make/squirrel.windows/x64/RELEASES ./builds/RELEASES
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: affine-windows-x64-builds
path: builds
make-linux:
runs-on: ubuntu-latest
environment: ${{ github.ref_name == 'master' && 'production' || 'development' }}
env:
NEXT_PUBLIC_FIREBASE_API_KEY: ${{ secrets.NEXT_PUBLIC_FIREBASE_API_KEY }}
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN: ${{ secrets.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN }}
NEXT_PUBLIC_FIREBASE_PROJECT_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_PROJECT_ID }}
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET: ${{ secrets.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET }}
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID }}
NEXT_PUBLIC_FIREBASE_APP_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_APP_ID }}
NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID: ${{ secrets.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID }}
AFFINE_GOOGLE_CLIENT_ID: ${{ secrets.AFFINE_GOOGLE_CLIENT_ID }}
AFFINE_GOOGLE_CLIENT_SECRET: ${{ secrets.AFFINE_GOOGLE_CLIENT_SECRET }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
NEXT_PUBLIC_SENTRY_DSN: ${{ secrets.NEXT_PUBLIC_SENTRY_DSN }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
API_SERVER_PROFILE: prod
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: ./.github/actions/setup-node
with:
electron-workspace-install: true
- name: make build
run: yarn make
working-directory: apps/electron
- name: Save Linux artifacts
run: |
mkdir -p builds
mv apps/electron/out/*/make/zip/linux/x64/*.zip ./builds/affine-${{ env.BUILD_TYPE }}-linux-x64.zip
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: affine-Linux-x64-builds
path: builds
release:
needs: [make-macos, make-windows]
needs: [make-macos, make-windows, make-linux]
runs-on: ubuntu-latest
steps:
- name: Download MacOS x64 Artifacts
@ -171,6 +196,11 @@ jobs:
with:
name: affine-windows-x64-builds
path: ./
- name: Download Linux Artifacts
uses: actions/download-artifact@v3
with:
name: affine-Linux-x64-builds
path: ./
- name: Create Release Draft
uses: softprops/action-gh-release@v1

View File

@ -1,7 +1,30 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const {
utils: { fromBuildIdentifier },
} = require('@electron-forge/core');
const isCanary = process.env.BUILD_TYPE === 'canary';
const productName = isCanary ? 'AFFiNE-Canary' : 'AFFiNE';
const icoPath = isCanary
? './resources/icons/icon_canary.ico'
: './resources/icons/icon.ico';
const icnsPath = isCanary
? './resources/icons/icon_canary.icns'
: './resources/icons/icon.icns';
/**
* @type {import('@electron-forge/shared-types').ForgeConfig}
*/
module.exports = {
buildIdentifier: isCanary ? 'canary' : 'stable',
packagerConfig: {
name: 'AFFiNE',
icon: './resources/icons/icon.icns',
name: productName,
appBundleId: fromBuildIdentifier({
canary: 'pro.affine.canary',
stable: 'pro.affine.app',
}),
icon: icnsPath,
osxSign: {
identity: 'Developer ID Application: TOEVERYTHING PTE. LTD.',
'hardened-runtime': true,
@ -20,7 +43,7 @@ module.exports = {
name: '@electron-forge/maker-dmg',
config: {
format: 'ULFO',
icon: './resources/icons/icon.icns',
icon: icnsPath,
name: 'AFFiNE',
},
},
@ -28,20 +51,26 @@ module.exports = {
name: '@electron-forge/maker-zip',
config: {
name: 'affine',
iconUrl: './resources/icons/icon.ico',
setupIcon: './resources/icons/icon.ico',
iconUrl: icoPath,
setupIcon: icoPath,
platforms: ['darwin', 'linux', 'win32'],
},
},
{
name: '@electron-forge/maker-squirrel',
config: {
name: 'AFFiNE',
setupIcon: './resources/icons/icon.ico',
setupIcon: icoPath,
// loadingGif: './resources/icons/loading.gif',
},
},
],
hooks: {
readPackageJson: async (_, packageJson) => {
// we want different package name for canary build
// so stable and canary will not share the same app data
packageJson.productName = productName;
},
generateAssets: async (_, platform, arch) => {
const { $ } = await import('zx');

View File

@ -1,7 +1,6 @@
import * as os from 'node:os';
import path from 'node:path';
import { Storage } from '@affine/octobase-node';
import { app, shell } from 'electron';
import { BrowserWindow, ipcMain, nativeTheme } from 'electron';
import fs from 'fs-extra';
@ -16,16 +15,7 @@ fs.ensureDirSync(AFFINE_ROOT);
const logger = console;
// todo: rethink this
export const appState = {
storage: new Storage(path.join(AFFINE_ROOT, 'test.db')),
};
export const registerHandlers = () => {
ipcMain.handle('octo:workspace-sync', async (_, id) => {
return appState.storage.sync(id, '');
});
ipcMain.handle('ui:theme-change', async (_, theme) => {
nativeTheme.themeSource = theme;
logger.info('theme change', theme);

View File

@ -1,6 +1,5 @@
{
"name": "@affine/electron",
"productName": "AFFiNE",
"private": true,
"version": "0.5.3",
"author": "affine",
@ -14,11 +13,11 @@
"dev": "cross-env NODE_ENV=development node scripts/dev.mjs",
"prod": "cross-env NODE_ENV=production node scripts/dev.mjs",
"generate-assets": "zx scripts/generate-assets.mjs",
"package": "electron-forge package",
"make": "electron-forge make",
"make-macos-arm64": "electron-forge make --platform=darwin --arch=arm64",
"make-macos-x64": "electron-forge make --platform=darwin --arch=x64",
"make-windows-x64": "electron-forge make --platform=win32 --arch=x64",
"build:octobase-node": "yarn workspace @affine/octobase-node build",
"postinstall": "ELECTRON_RUN_AS_NODE=1 electron scripts/update-electron-vendors.mjs"
},
"config": {
@ -26,7 +25,6 @@
},
"main": "./dist/layers/main/index.js",
"devDependencies": {
"@affine/octobase-node": "workspace:*",
"@electron-forge/cli": "^6.1.1",
"@electron-forge/core": "^6.1.1",
"@electron-forge/core-utils": "^6.1.1",

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

View File

@ -60,17 +60,6 @@ await fs.move(affineWebOutDir, publicAffineOutDir, { overwrite: true });
await buildLayers();
echo('Build layers done');
// step 3: build octobase-node
let buildOctobaseNode = 'yarn workspace @affine/octobase-node build';
if (process.env.TARGET) {
buildOctobaseNode += ` --target=${process.env.TARGET}`;
}
await $([buildOctobaseNode]);
// step 4: copy octobase-node to electron dist
await fs.ensureDir('./apps/electron/dist/layers/main/');
await $`cp ./packages/octobase-node/octobase.*.node ./apps/electron/dist/layers/main/`;
/// --------
/// --------
/// --------

View File

@ -115,7 +115,6 @@ __metadata:
version: 0.0.0-use.local
resolution: "@affine/electron@workspace:."
dependencies:
"@affine/octobase-node": "workspace:*"
"@electron-forge/cli": ^6.1.1
"@electron-forge/core": ^6.1.1
"@electron-forge/core-utils": ^6.1.1
@ -192,7 +191,7 @@ __metadata:
languageName: unknown
linkType: soft
"@affine/octobase-node@workspace:*, @affine/octobase-node@workspace:../../packages/octobase-node":
"@affine/octobase-node@workspace:../../packages/octobase-node":
version: 0.0.0-use.local
resolution: "@affine/octobase-node@workspace:../../packages/octobase-node"
dependencies: