Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

build: add canary build (#1986)

Peng Xiao11de3a681f39
diff --git a/.github/workflows/release-desktop-app.yml b/.github/workflows/release-desktop-app.yml
index 925ab06577..b8aec50537 100644
--- a/.github/workflows/release-desktop-app.yml
+++ b/.github/workflows/release-desktop-app.yml
@@ -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
diff --git a/apps/electron/forge.config.js b/apps/electron/forge.config.js
index e436b709ec..5f9428b34b 100644
--- a/apps/electron/forge.config.js
+++ b/apps/electron/forge.config.js
@@ -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');
diff --git a/apps/electron/layers/main/src/app-state/index.ts b/apps/electron/layers/main/src/app-state/index.ts
index d2bbc1390d..fdda5dc647 100644
--- a/apps/electron/layers/main/src/app-state/index.ts
+++ b/apps/electron/layers/main/src/app-state/index.ts
@@ -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);
diff --git a/apps/electron/package.json b/apps/electron/package.json
index 069ac790cc..45d1dcfbc8 100644
--- a/apps/electron/package.json
+++ b/apps/electron/package.json
@@ -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",
diff --git a/apps/electron/resources/icons/icon_canary.icns b/apps/electron/resources/icons/icon_canary.icns
new file mode 100644
index 0000000000..9a0a8be2b7
Binary files /dev/null and b/apps/electron/resources/icons/icon_canary.icns differ
diff --git a/apps/electron/resources/icons/icon_canary.ico b/apps/electron/resources/icons/icon_canary.ico
new file mode 100644
index 0000000000..5c593fdafa
Binary files /dev/null and b/apps/electron/resources/icons/icon_canary.ico differ
diff --git a/apps/electron/scripts/generate-assets.mjs b/apps/electron/scripts/generate-assets.mjs
index afd21c8e25..9c09f526a2 100644
--- a/apps/electron/scripts/generate-assets.mjs
+++ b/apps/electron/scripts/generate-assets.mjs
@@ -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/`;
-
/// --------
/// --------
/// --------
diff --git a/apps/electron/yarn.lock b/apps/electron/yarn.lock
index 54aa6b0717..5e64ab70b0 100644
--- a/apps/electron/yarn.lock
+++ b/apps/electron/yarn.lock
@@ -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: