Skip to content

Commit

Permalink
build(electron): add internal release channel (#2309)
Browse files Browse the repository at this point in the history
  • Loading branch information
himself65 authored May 11, 2023
1 parent dc4979a commit f82ea5d
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 42 deletions.
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

2 comments on commit f82ea5d

@vercel
Copy link

@vercel vercel bot commented on f82ea5d May 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on f82ea5d May 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

affine-storybook – ./packages/component

affine-storybook-toeverything.vercel.app
affine-storybook-git-master-toeverything.vercel.app
affine-storybook.vercel.app
storybook.affine.pro

Please # to comment.