build(electron): add nsis build to release-desktop workflow (#6677)

Updater may break after this PR and will be fixed in the next one

After this PR, we will have two windows installer options
- affine-0.14.0-canary.9-canary-windows-x64.exe
- affine-0.14.0-canary.9-canary-windows-x64.nsis.exe (added)
This commit is contained in:
pengx17
2024-04-25 03:52:27 +00:00
parent 0b380f94c7
commit bfcf4a105e
3 changed files with 16 additions and 11 deletions

View File

@@ -260,6 +260,10 @@ jobs:
- name: Setup Node.js - name: Setup Node.js
timeout-minutes: 10 timeout-minutes: 10
uses: ./.github/actions/setup-node uses: ./.github/actions/setup-node
with:
extra-flags: workspaces focus @affine/electron @affine/monorepo
hard-link-nm: false
nmHoistingLimits: workspaces
- name: Download and overwrite packaged artifacts - name: Download and overwrite packaged artifacts
uses: actions/download-artifact@v4 uses: actions/download-artifact@v4
with: with:
@@ -271,6 +275,9 @@ jobs:
- name: Make squirrel.windows installer - name: Make squirrel.windows installer
run: yarn workspace @affine/electron make-squirrel --platform=${{ matrix.spec.platform }} --arch=${{ matrix.spec.arch }} run: yarn workspace @affine/electron make-squirrel --platform=${{ matrix.spec.platform }} --arch=${{ matrix.spec.arch }}
- name: Make nsis.windows installer
run: yarn workspace @affine/electron make-nsis --platform=${{ matrix.spec.platform }} --arch=${{ matrix.spec.arch }}
- name: Zip artifacts for faster upload - name: Zip artifacts for faster upload
run: Compress-Archive -CompressionLevel Fastest -Path packages/frontend/electron/out/${{ env.BUILD_TYPE }}/make/* -DestinationPath archive.zip run: Compress-Archive -CompressionLevel Fastest -Path packages/frontend/electron/out/${{ env.BUILD_TYPE }}/make/* -DestinationPath archive.zip
@@ -318,7 +325,7 @@ jobs:
mkdir -p builds mkdir -p builds
mv packages/frontend/electron/out/*/make/zip/win32/x64/AFFiNE*-win32-x64-*.zip ./builds/affine-${{ needs.before-make.outputs.RELEASE_VERSION }}-${{ env.BUILD_TYPE }}-windows-x64.zip mv packages/frontend/electron/out/*/make/zip/win32/x64/AFFiNE*-win32-x64-*.zip ./builds/affine-${{ needs.before-make.outputs.RELEASE_VERSION }}-${{ env.BUILD_TYPE }}-windows-x64.zip
mv packages/frontend/electron/out/*/make/squirrel.windows/x64/*.exe ./builds/affine-${{ needs.before-make.outputs.RELEASE_VERSION }}-${{ env.BUILD_TYPE }}-windows-x64.exe mv packages/frontend/electron/out/*/make/squirrel.windows/x64/*.exe ./builds/affine-${{ needs.before-make.outputs.RELEASE_VERSION }}-${{ env.BUILD_TYPE }}-windows-x64.exe
mv packages/frontend/electron/out/*/make/squirrel.windows/x64/*.msi ./builds/affine-${{ needs.before-make.outputs.RELEASE_VERSION }}-${{ env.BUILD_TYPE }}-windows-x64.msi mv packages/frontend/electron/out/*/make/nsis.windows/x64/*.exe ./builds/affine-${{ needs.before-make.outputs.RELEASE_VERSION }}-${{ env.BUILD_TYPE }}-windows-x64.snis.exe
- name: Upload Artifact - name: Upload Artifact
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4

View File

@@ -16,7 +16,7 @@ import {
ROOT, ROOT,
} from './make-env.js'; } from './make-env.js';
const log = debug('electron-forge:make-nsis'); const log = debug('make-nsis');
async function make() { async function make() {
const appName = productName; const appName = productName;
@@ -44,6 +44,8 @@ async function make() {
{ dir: tmpPath }, { dir: tmpPath },
{ {
win: [`nsis:${arch}`], win: [`nsis:${arch}`],
// @ts-expect-error - upstream type is wrong
publish: null, // buildForge will incorrectly publish the build
config: { config: {
appId: appIdMap[buildType], appId: appIdMap[buildType],
productName, productName,
@@ -73,7 +75,7 @@ async function make() {
); );
// Move the output to the actual output folder, app-builder-lib might get it wrong // Move the output to the actual output folder, app-builder-lib might get it wrong
log('Received output files', output); log('making nsis.windows done:', output);
const result: Array<string> = []; const result: Array<string> = [];
for (const file of output) { for (const file of output) {

View File

@@ -1,5 +1,6 @@
import path from 'node:path'; import path from 'node:path';
import debug from 'debug';
import type { Options as ElectronWinstallerOptions } from 'electron-winstaller'; import type { Options as ElectronWinstallerOptions } from 'electron-winstaller';
import { convertVersion, createWindowsInstaller } from 'electron-winstaller'; import { convertVersion, createWindowsInstaller } from 'electron-winstaller';
import fs from 'fs-extra'; import fs from 'fs-extra';
@@ -14,12 +15,7 @@ import {
ROOT, ROOT,
} from './make-env.js'; } from './make-env.js';
async function ensureDirectory(dir: string) { const log = debug('make-squirrel');
if (await fs.pathExists(dir)) {
await fs.remove(dir);
}
return fs.mkdirs(dir);
}
// taking from https://github.com/electron/forge/blob/main/packages/maker/squirrel/src/MakerSquirrel.ts // taking from https://github.com/electron/forge/blob/main/packages/maker/squirrel/src/MakerSquirrel.ts
// it was for forge's maker, but can be used standalone as well // it was for forge's maker, but can be used standalone as well
@@ -33,7 +29,7 @@ async function make() {
buildType, buildType,
`${appName}-${platform}-${arch}` `${appName}-${platform}-${arch}`
); );
await ensureDirectory(outPath); await fs.ensureDir(outPath);
const packageJSON = await fs.readJson(path.resolve(ROOT, 'package.json')); const packageJSON = await fs.readJson(path.resolve(ROOT, 'package.json'));
@@ -78,7 +74,7 @@ async function make() {
if (!winstallerConfig.noMsi && (await fs.pathExists(msiPath))) { if (!winstallerConfig.noMsi && (await fs.pathExists(msiPath))) {
artifacts.push(msiPath); artifacts.push(msiPath);
} }
console.log('making squirrel.windows done:', artifacts); log('making squirrel.windows done:', artifacts);
return artifacts; return artifacts;
} }