build(electron): add internal release channel (#2309)

This commit is contained in:
Himself65
2023-05-11 10:42:56 +08:00
committed by GitHub
parent dc4979a80c
commit f82ea5d9c4
9 changed files with 87 additions and 42 deletions

View File

@@ -21,7 +21,8 @@ concurrency:
cancel-in-progress: true cancel-in-progress: true
env: env:
BUILD_TYPE: canary BUILD_TYPE: internal
RELEASE_VERSION: ${{ github.ref_name }}-${{ github.sha }}
jobs: jobs:
before-make: before-make:
@@ -136,3 +137,62 @@ jobs:
with: with:
name: affine-${{ matrix.spec.platform }}-${{ matrix.spec.arch }}-builds name: affine-${{ matrix.spec.platform }}-${{ matrix.spec.arch }}-builds
path: 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

View File

@@ -1,11 +1,16 @@
/* eslint-disable @typescript-eslint/no-var-requires */ /* eslint-disable @typescript-eslint/no-var-requires */
const { z } = require('zod');
const { const {
utils: { fromBuildIdentifier }, utils: { fromBuildIdentifier },
} = require('@electron-forge/core'); } = require('@electron-forge/core');
const path = require('node:path'); 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 stableBuild = buildType === 'stable';
const productName = !stableBuild ? `AFFiNE-${buildType}` : 'AFFiNE'; const productName = !stableBuild ? `AFFiNE-${buildType}` : 'AFFiNE';
const icoPath = !stableBuild const icoPath = !stableBuild

View File

@@ -1,8 +1,8 @@
import type { NamespaceHandlers } from '../type'; import type { NamespaceHandlers } from '../type';
import { updateClient } from './updater';
export const updaterHandlers = { export const updaterHandlers = {
updateClient: async () => { updateClient: async () => {
const { updateClient } = await import('./updater');
return updateClient(); return updateClient();
}, },
} satisfies NamespaceHandlers; } satisfies NamespaceHandlers;

View File

@@ -1,10 +1,21 @@
import type { AppUpdater } from 'electron-updater'; import type { AppUpdater } from 'electron-updater';
import { z } from 'zod';
import { isMacOS } from '../../../../utils'; import { isMacOS } from '../../../../utils';
import { updaterSubjects } from '../../events/updater'; import { updaterSubjects } from '../../events/updater';
import { logger } from '../../logger'; 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 mode = process.env.NODE_ENV;
const isDev = mode === 'development'; const isDev = mode === 'development';
@@ -17,8 +28,7 @@ export const updateClient = async () => {
export const registerUpdater = async () => { export const registerUpdater = async () => {
// require it will cause some side effects and will break generate-main-exposed-meta, // require it will cause some side effects and will break generate-main-exposed-meta,
// so we wrap it in a function // so we wrap it in a function
// eslint-disable-next-line @typescript-eslint/no-var-requires const { autoUpdater } = await import('electron-updater');
const { autoUpdater } = require('electron-updater');
_autoUpdater = autoUpdater; _autoUpdater = autoUpdater;
@@ -33,7 +43,7 @@ export const registerUpdater = async () => {
_autoUpdater.setFeedURL({ _autoUpdater.setFeedURL({
channel: buildType, channel: buildType,
provider: 'github', provider: 'github',
repo: 'AFFiNE', repo: buildType !== 'internal' ? 'AFFiNE' : 'AFFiNE-Releases',
owner: 'toeverything', owner: 'toeverything',
releaseType: buildType === 'stable' ? 'release' : 'prerelease', releaseType: buildType === 'stable' ? 'release' : 'prerelease',
}); });

View File

@@ -1,15 +0,0 @@
{
"compilerOptions": {
"module": "esnext",
"target": "esnext",
"sourceMap": false,
"moduleResolution": "Node",
"skipLibCheck": true,
"strict": true,
"isolatedModules": true,
"allowSyntheticDefaultImports": true,
"types": ["node"]
},
"include": ["src/**/*.ts", "../../types/**/*.d.ts", "index.ts", "../utils.ts"]
}

View File

@@ -1,14 +0,0 @@
{
"compilerOptions": {
"module": "esnext",
"target": "esnext",
"sourceMap": false,
"moduleResolution": "Node",
"skipLibCheck": true,
"strict": true,
"isolatedModules": true,
"types": ["node"]
},
"include": ["src/**/*.ts", "../../types/**/*.d.ts"]
}

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

View File

@@ -1,19 +1,18 @@
{ {
"extends": "../../tsconfig.json", "extends": "../../tsconfig.json",
"compilerOptions": { "compilerOptions": {
"composite": true, "skipLibCheck": true,
"target": "ESNext", "target": "ESNext",
"module": "ESNext", "module": "ESNext",
"emitDecoratorMetadata": true, "emitDecoratorMetadata": true,
"experimentalDecorators": true, "experimentalDecorators": true,
"moduleResolution": "bundler",
"isolatedModules": false,
"resolveJsonModule": true,
"types": ["node"], "types": ["node"],
"outDir": "dist", "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"], "exclude": ["out", "dist", "node_modules"],
"references": [ "references": [
{ {