From 2cc29833df08adeb00882f6ebb11f9cd112f517b Mon Sep 17 00:00:00 2001 From: PiEgg Date: Tue, 9 Dec 2025 17:42:22 +0800 Subject: [PATCH] :package: Chore: update builder config && add legacy version file upload process --- electron-builder.config.ts | 21 ++++++++------- scripts/config.js | 54 +++++++++++++++++++------------------- scripts/upload-dist.js | 33 ++++++++++++++++++++++- 3 files changed, 71 insertions(+), 37 deletions(-) diff --git a/electron-builder.config.ts b/electron-builder.config.ts index 9ec1b19..36c7024 100644 --- a/electron-builder.config.ts +++ b/electron-builder.config.ts @@ -4,14 +4,16 @@ import type { Configuration } from 'electron-builder' const config: Configuration = { appId: 'com.molunerfinn.picgo', productName: 'PicGo', - publish: [ - { - provider: 'github', - owner: 'Molunerfinn', - repo: 'PicGo', - releaseType: 'draft' - } - ], + // publish: [ + // { + // provider: 'github', + // owner: 'Molunerfinn', + // repo: 'PicGo', + // releaseType: 'draft' + // } + // ], + // temporarily disable auto update feature + publish: [], files: [ 'dist_electron/**/*', 'node_modules/**/*', @@ -98,7 +100,8 @@ const config: Configuration = { } ], maintainer: 'Molunerfinn', - category: 'Utility' + category: 'Utility', + publish: [] } } diff --git a/scripts/config.js b/scripts/config.js index c3925e5..e41c654 100644 --- a/scripts/config.js +++ b/scripts/config.js @@ -2,60 +2,60 @@ // macos (dmg, x64 + arm64) const darwin = [{ - appNameWithPrefix: 'PicGo-', - ext: '.dmg', - arch: '-arm64', + appNameWithPrefix: 'PicGo', + ext: 'dmg', + arch: 'arm64', 'version-file': 'latest-mac.yml' }, { - appNameWithPrefix: 'PicGo-', - ext: '.dmg', - arch: '-x64', + appNameWithPrefix: 'PicGo', + ext: 'dmg', + arch: 'x64', 'version-file': 'latest-mac.yml' }] // linux (AppImage, deb, snap) const linux = [{ - appNameWithPrefix: 'PicGo-', - ext: '.AppImage', - arch: '-arm64', + appNameWithPrefix: 'PicGo', + ext: 'AppImage', + arch: 'arm64', 'version-file': 'latest-linux-arm64.yml' }, { - appNameWithPrefix: 'PicGo-', - ext: '.AppImage', + appNameWithPrefix: 'PicGo', + ext: 'AppImage', arch: 'x86_64', 'version-file': 'latest-linux.yml' }, { - appNameWithPrefix: 'PicGo-', - ext: '.deb', - arch: '-arm64', + appNameWithPrefix: 'PicGo', + ext: 'deb', + arch: 'arm64', 'version-file': 'latest-linux-arm64.yml' }, { - appNameWithPrefix: 'PicGo-', - ext: '.deb', + appNameWithPrefix: 'PicGo', + ext: 'deb', arch: 'amd64', 'version-file': 'latest-linux.yml' }, { - appNameWithPrefix: 'PicGo-', - ext: '.snap', + appNameWithPrefix: 'PicGo', + ext: 'snap', arch: 'amd64', 'version-file': 'latest-linux.yml' }] // windows (nsis, x64 + ia32 + arm64) const win32 = [{ - appNameWithPrefix: 'PicGo-', - ext: '.exe', - arch: '-ia32', + appNameWithPrefix: 'PicGo', + ext: 'exe', + arch: 'ia32', 'version-file': 'latest.yml' }, { - appNameWithPrefix: 'PicGo-', - ext: '.exe', - arch: '-x64', + appNameWithPrefix: 'PicGo', + ext: 'exe', + arch: 'x64', 'version-file': 'latest.yml' }, { - appNameWithPrefix: 'PicGo-', - ext: '.exe', - arch: '-arm64', + appNameWithPrefix: 'PicGo', + ext: 'exe', + arch: 'arm64', 'version-file': 'latest.yml' }] diff --git a/scripts/upload-dist.js b/scripts/upload-dist.js index 26954b8..b464bf2 100644 --- a/scripts/upload-dist.js +++ b/scripts/upload-dist.js @@ -17,12 +17,16 @@ const Upload = require('@aws-sdk/lib-storage').Upload // const COS_SECRET_KEY = process.env.PICGO_ENV_COS_SECRET_KEY const S3_BUCKET = 'release' +const S3_LEGACY_BUCKET = 'picgo' // const AREA = 'ap-chengdu' const VERSION = pkg.version const FILE_PATH = `${VERSION}/` const S3_SECRET_ID = process.env.PICGO_ENV_S3_SECRET_ID const S3_SECRET_KEY = process.env.PICGO_ENV_S3_SECRET_KEY const S3_ACCOUNT_ID = process.env.PICGO_ENV_S3_ACCOUNT_ID +const S3_LEGACY_SECRET_ID = process.env.PICGO_ENV_S3_LEGACY_SECRET_ID +const S3_LEGACY_SECRET_KEY = process.env.PICGO_ENV_S3_LEGACY_SECRET_KEY +const S3_LEGACY_ACCOUNT_ID = process.env.PICGO_ENV_S3_LEGACY_ACCOUNT_ID const S3Options = { credentials: { @@ -34,6 +38,17 @@ const S3Options = { region: 'auto' } +// for legacy release file fetch +const S3LegacyOptions = { + credentials: { + accessKeyId: S3_LEGACY_SECRET_ID, + secretAccessKey: S3_LEGACY_SECRET_KEY + }, + endpoint: `https://${S3_LEGACY_ACCOUNT_ID}.r2.cloudflarestorage.com`, + sslEnabled: true, + region: 'auto' +} + // https://cloud.tencent.com/document/product/436/7778#signature // /** // * @param {string} fileName @@ -119,13 +134,14 @@ const uploadDist = async () => { if (configList[platform]) { const uploadedVersionFiles = new Set() for (const [index, config] of configList[platform].entries()) { - const fileName = `${config.appNameWithPrefix}${VERSION}${config.arch}${config.ext}` + const fileName = `${config.appNameWithPrefix}-${VERSION}-${config.arch}.${config.ext}` const filePath = path.join(distPath, fileName) const versionFilePath = path.join(distPath, config['version-file']) let versionFileName = config['version-file'] if (VERSION.toLocaleLowerCase().includes('beta')) { versionFileName = versionFileName.replace('.yml', '.beta.yml') } + console.log('[PicGo Dist] Preparing to upload', fileName) const client = new S3Client(S3Options) if (fs.existsSync(filePath)) { const uploadDistToS3 = new Upload({ @@ -143,6 +159,8 @@ const uploadDist = async () => { console.log(`[PicGo Dist] Uploading... ${progress.loaded}/${progress.total}`) }) await uploadDistToS3.done() + } else { + console.warn('[PicGo Dist] File not found:', fileName) } // upload version file @@ -156,8 +174,21 @@ const uploadDist = async () => { ContentType: mime.lookup(versionFileName) } }) + // upload to legacy bucket as well + // will be deprecated in 2.5.0 + const legacyClient = new S3Client(S3LegacyOptions) + const uploadVersionFileToLegacyS3 = new Upload({ + client: legacyClient, + params: { + Bucket: S3_LEGACY_BUCKET, + Key: `${versionFileName}`, + Body: fs.createReadStream(versionFilePath), + ContentType: mime.lookup(versionFileName) + } + }) console.log('[PicGo Version File] Uploading...', versionFileName) await uploadVersionFileToS3.done() + await uploadVersionFileToLegacyS3.done() uploadedVersionFiles.add(versionFileName) console.log('[PicGo Version File] Upload successfully') }