Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

build(electron): add internal release channel #2309

Merged
merged 10 commits into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 61 additions & 1 deletion .github/workflows/nightly-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ concurrency:
cancel-in-progress: true

env:
BUILD_TYPE: canary
BUILD_TYPE: internal
RELEASE_VERSION: ${{ github.ref_name }}-${{ github.sha }}

jobs:
before-make:
Expand Down Expand Up @@ -136,3 +137,62 @@ jobs:
with:
name: affine-${{ matrix.spec.platform }}-${{ matrix.spec.arch }}-builds
path: builds

release:
needs: make-distribution
runs-on: ubuntu-latest

steps:
- name: Download Artifacts (macos-x64)
uses: actions/download-artifact@v3
with:
name: affine-macos-x64-builds
path: ./
- name: Download Artifacts (macos-arm64)
uses: actions/download-artifact@v3
with:
name: affine-macos-arm64-builds
path: ./
- name: Download Artifacts (windows-x64)
uses: actions/download-artifact@v3
with:
name: affine-windows-x64-builds
path: ./
- name: Download Artifacts (linux-x64)
uses: actions/download-artifact@v3
with:
name: affine-linux-x64-builds
path: ./
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
name: release-yml-build-script
path: ./
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- name: Generate Release yml
run: |
node generate-yml.js
env:
RELEASE_VERSION: ${{ env.RELEASE_VERSION }}
- name: Create Release Draft
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
with:
repository: 'toeverything/AFFiNE-Releases'
name: ${{ env.RELEASE_VERSION }}
tag_name: ${{ env.RELEASE_VERSION }}
prerelease: true
files: |
./VERSION
./*.zip
./*.dmg
./*.exe
./*.nupkg
./RELEASES
./*.AppImage
./*.apk
./*.yml
7 changes: 6 additions & 1 deletion apps/electron/forge.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const { z } = require('zod');

const {
utils: { fromBuildIdentifier },
} = require('@electron-forge/core');

const path = require('node:path');

const buildType = (process.env.BUILD_TYPE || 'stable').trim().toLowerCase();
const ReleaseTypeSchema = z.enum(['stable', 'beta', 'canary', 'internal']);

const envBuildType = (process.env.BUILD_TYPE || 'canary').trim().toLowerCase();
const buildType = ReleaseTypeSchema.parse(envBuildType);
const stableBuild = buildType === 'stable';
const productName = !stableBuild ? `AFFiNE-${buildType}` : 'AFFiNE';
const icoPath = !stableBuild
Expand Down
2 changes: 1 addition & 1 deletion apps/electron/layers/main/src/handlers/updater/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { NamespaceHandlers } from '../type';
import { updateClient } from './updater';

export const updaterHandlers = {
updateClient: async () => {
const { updateClient } = await import('./updater');
return updateClient();
},
} satisfies NamespaceHandlers;
Expand Down
18 changes: 14 additions & 4 deletions apps/electron/layers/main/src/handlers/updater/updater.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
import type { AppUpdater } from 'electron-updater';
import { z } from 'zod';

import { isMacOS } from '../../../../utils';
import { updaterSubjects } from '../../events/updater';
import { logger } from '../../logger';

const buildType = (process.env.BUILD_TYPE || 'canary').trim().toLowerCase();
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';

Expand All @@ -17,8 +28,7 @@ export const updateClient = async () => {
export const registerUpdater = async () => {
// require it will cause some side effects and will break generate-main-exposed-meta,
// so we wrap it in a function
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { autoUpdater } = require('electron-updater');
const { autoUpdater } = await import('electron-updater');

_autoUpdater = autoUpdater;

Expand All @@ -33,7 +43,7 @@ export const registerUpdater = async () => {
_autoUpdater.setFeedURL({
channel: buildType,
provider: 'github',
repo: 'AFFiNE',
repo: buildType !== 'internal' ? 'AFFiNE' : 'AFFiNE-Releases',
owner: 'toeverything',
releaseType: buildType === 'stable' ? 'release' : 'prerelease',
});
Expand Down
15 changes: 0 additions & 15 deletions apps/electron/layers/main/tsconfig.json

This file was deleted.

14 changes: 0 additions & 14 deletions apps/electron/layers/preload/tsconfig.json

This file was deleted.

Binary file added apps/electron/resources/icons/icon_internal.icns
Binary file not shown.
Binary file added apps/electron/resources/icons/icon_internal.ico
Binary file not shown.
11 changes: 5 additions & 6 deletions apps/electron/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"skipLibCheck": true,
"target": "ESNext",
"module": "ESNext",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"moduleResolution": "bundler",
"isolatedModules": false,
"resolveJsonModule": true,
"types": ["node"],
"outDir": "dist",
"noEmit": false
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true
},
"include": ["layers", "types", "package.json"],
"include": ["**/*.ts", "**/*.tsx", "package.json"],
"exclude": ["out", "dist", "node_modules"],
"references": [
{
Expand Down