fix(electron): electron updater issues (#6005)

- generate-yml.js does not filter files correctly
- add version to generated bundles
- change `.AppImage` to `.appimage`. See https://github.com/electron-userland/electron-builder/blob/master/packages/electron-updater/src/providers/Provider.ts#L88
This commit is contained in:
Peng Xiao
2024-03-05 03:27:51 +00:00
parent a9be19ce6c
commit 3fcbfe4d30
3 changed files with 16 additions and 18 deletions

View File

@@ -139,14 +139,14 @@ jobs:
if: ${{ matrix.spec.platform == 'darwin' }} if: ${{ matrix.spec.platform == 'darwin' }}
run: | run: |
mkdir -p builds mkdir -p builds
mv packages/frontend/electron/out/*/make/*.dmg ./builds/affine-${{ env.BUILD_TYPE }}-macos-${{ matrix.spec.arch }}.dmg mv packages/frontend/electron/out/*/make/*.dmg ./builds/affine-${{ needs.before-make.outputs.RELEASE_VERSION }}-${{ env.BUILD_TYPE }}-macos-${{ matrix.spec.arch }}.dmg
mv packages/frontend/electron/out/*/make/zip/darwin/${{ matrix.spec.arch }}/*.zip ./builds/affine-${{ env.BUILD_TYPE }}-macos-${{ matrix.spec.arch }}.zip mv packages/frontend/electron/out/*/make/zip/darwin/${{ matrix.spec.arch }}/*.zip ./builds/affine-${{ needs.before-make.outputs.RELEASE_VERSION }}-${{ env.BUILD_TYPE }}-macos-${{ matrix.spec.arch }}.zip
- name: Save artifacts (linux) - name: Save artifacts (linux)
if: ${{ matrix.spec.platform == 'linux' }} if: ${{ matrix.spec.platform == 'linux' }}
run: | run: |
mkdir -p builds mkdir -p builds
mv packages/frontend/electron/out/*/make/zip/linux/x64/*.zip ./builds/affine-${{ env.BUILD_TYPE }}-linux-x64.zip mv packages/frontend/electron/out/*/make/zip/linux/x64/*.zip ./builds/affine-${{ needs.before-make.outputs.RELEASE_VERSION }}-${{ env.BUILD_TYPE }}-linux-x64.zip
mv packages/frontend/electron/out/*/make/*.AppImage ./builds/affine-${{ env.BUILD_TYPE }}-linux-x64.AppImage mv packages/frontend/electron/out/*/make/*.AppImage ./builds/affine-${{ needs.before-make.outputs.RELEASE_VERSION }}-${{ env.BUILD_TYPE }}-linux-x64.appimage
- name: Upload Artifact - name: Upload Artifact
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
@@ -299,9 +299,9 @@ jobs:
- name: Save artifacts - name: Save artifacts
run: | run: |
mkdir -p builds mkdir -p builds
mv packages/frontend/electron/out/*/make/zip/win32/x64/AFFiNE*-win32-x64-*.zip ./builds/affine-${{ 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-${{ 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-${{ env.BUILD_TYPE }}-windows-x64.msi mv packages/frontend/electron/out/*/make/squirrel.windows/x64/*.msi ./builds/affine-${{ needs.before-make.outputs.RELEASE_VERSION }}-${{ env.BUILD_TYPE }}-windows-x64.msi
- name: Upload Artifact - name: Upload Artifact
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
@@ -362,7 +362,7 @@ jobs:
./*.zip ./*.zip
./*.dmg ./*.dmg
./*.exe ./*.exe
./*.AppImage ./*.appimage
./*.apk ./*.apk
./*.yml ./*.yml
- name: Create Nightly Release Draft - name: Create Nightly Release Draft
@@ -384,6 +384,6 @@ jobs:
./*.zip ./*.zip
./*.dmg ./*.dmg
./*.exe ./*.exe
./*.AppImage ./*.appimage
./*.apk ./*.apk
./*.yml ./*.yml

View File

@@ -2,11 +2,6 @@ import crypto from 'node:crypto';
import fs from 'node:fs'; import fs from 'node:fs';
import path from 'node:path'; import path from 'node:path';
const yml = {
version: process.env.RELEASE_VERSION ?? '0.0.0',
files: [],
};
const filenamesMapping = { const filenamesMapping = {
windows: 'latest.yml', windows: 'latest.yml',
macos: 'latest-mac.yml', macos: 'latest-mac.yml',
@@ -14,7 +9,11 @@ const filenamesMapping = {
}; };
const generateYml = platform => { const generateYml = platform => {
const regex = new RegExp(`^affine-.*-${platform}-.*.(exe|zip|dmg|AppImage)$`); const yml = {
version: process.env.RELEASE_VERSION ?? '0.0.0',
files: [],
};
const regex = new RegExp(`^affine-.*-${platform}-.*.(exe|zip|dmg|appimage)$`);
const files = fs.readdirSync(process.cwd()).filter(file => regex.test(file)); const files = fs.readdirSync(process.cwd()).filter(file => regex.test(file));
const outputFileName = filenamesMapping[platform]; const outputFileName = filenamesMapping[platform];
@@ -35,6 +34,7 @@ const generateYml = platform => {
}); });
} catch (e) {} } catch (e) {}
}); });
// path & sha512 are deprecated
yml.path = yml.files[0].url; yml.path = yml.files[0].url;
yml.sha512 = yml.files[0].sha512; yml.sha512 = yml.files[0].sha512;
yml.releaseDate = new Date().toISOString(); yml.releaseDate = new Date().toISOString();

View File

@@ -1,7 +1,6 @@
import { app } from 'electron'; import { app } from 'electron';
import { autoUpdater } from 'electron-updater'; import { autoUpdater } from 'electron-updater';
import { isMacOS, isWindows } from '../../shared/utils';
import { buildType } from '../config'; import { buildType } from '../config';
import { logger } from '../logger'; import { logger } from '../logger';
import { CustomGitHubProvider } from './custom-github-provider'; import { CustomGitHubProvider } from './custom-github-provider';
@@ -82,8 +81,7 @@ export const registerUpdater = async () => {
return; return;
} }
// TODO: support auto update on linux const allowAutoUpdate = true;
const allowAutoUpdate = isMacOS() || isWindows();
autoUpdater.logger = logger; autoUpdater.logger = logger;
autoUpdater.autoDownload = false; autoUpdater.autoDownload = false;