mirror of
https://github.com/Molunerfinn/PicGo.git
synced 2026-10-19 16:14:41 +00:00
📦 Chore: update builder config && add legacy version file upload process
This commit is contained in:
@@ -4,14 +4,16 @@ import type { Configuration } from 'electron-builder'
|
|||||||
const config: Configuration = {
|
const config: Configuration = {
|
||||||
appId: 'com.molunerfinn.picgo',
|
appId: 'com.molunerfinn.picgo',
|
||||||
productName: 'PicGo',
|
productName: 'PicGo',
|
||||||
publish: [
|
// publish: [
|
||||||
{
|
// {
|
||||||
provider: 'github',
|
// provider: 'github',
|
||||||
owner: 'Molunerfinn',
|
// owner: 'Molunerfinn',
|
||||||
repo: 'PicGo',
|
// repo: 'PicGo',
|
||||||
releaseType: 'draft'
|
// releaseType: 'draft'
|
||||||
}
|
// }
|
||||||
],
|
// ],
|
||||||
|
// temporarily disable auto update feature
|
||||||
|
publish: [],
|
||||||
files: [
|
files: [
|
||||||
'dist_electron/**/*',
|
'dist_electron/**/*',
|
||||||
'node_modules/**/*',
|
'node_modules/**/*',
|
||||||
@@ -98,7 +100,8 @@ const config: Configuration = {
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
maintainer: 'Molunerfinn',
|
maintainer: 'Molunerfinn',
|
||||||
category: 'Utility'
|
category: 'Utility',
|
||||||
|
publish: []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+27
-27
@@ -2,60 +2,60 @@
|
|||||||
|
|
||||||
// macos (dmg, x64 + arm64)
|
// macos (dmg, x64 + arm64)
|
||||||
const darwin = [{
|
const darwin = [{
|
||||||
appNameWithPrefix: 'PicGo-',
|
appNameWithPrefix: 'PicGo',
|
||||||
ext: '.dmg',
|
ext: 'dmg',
|
||||||
arch: '-arm64',
|
arch: 'arm64',
|
||||||
'version-file': 'latest-mac.yml'
|
'version-file': 'latest-mac.yml'
|
||||||
}, {
|
}, {
|
||||||
appNameWithPrefix: 'PicGo-',
|
appNameWithPrefix: 'PicGo',
|
||||||
ext: '.dmg',
|
ext: 'dmg',
|
||||||
arch: '-x64',
|
arch: 'x64',
|
||||||
'version-file': 'latest-mac.yml'
|
'version-file': 'latest-mac.yml'
|
||||||
}]
|
}]
|
||||||
|
|
||||||
// linux (AppImage, deb, snap)
|
// linux (AppImage, deb, snap)
|
||||||
const linux = [{
|
const linux = [{
|
||||||
appNameWithPrefix: 'PicGo-',
|
appNameWithPrefix: 'PicGo',
|
||||||
ext: '.AppImage',
|
ext: 'AppImage',
|
||||||
arch: '-arm64',
|
arch: 'arm64',
|
||||||
'version-file': 'latest-linux-arm64.yml'
|
'version-file': 'latest-linux-arm64.yml'
|
||||||
}, {
|
}, {
|
||||||
appNameWithPrefix: 'PicGo-',
|
appNameWithPrefix: 'PicGo',
|
||||||
ext: '.AppImage',
|
ext: 'AppImage',
|
||||||
arch: 'x86_64',
|
arch: 'x86_64',
|
||||||
'version-file': 'latest-linux.yml'
|
'version-file': 'latest-linux.yml'
|
||||||
}, {
|
}, {
|
||||||
appNameWithPrefix: 'PicGo-',
|
appNameWithPrefix: 'PicGo',
|
||||||
ext: '.deb',
|
ext: 'deb',
|
||||||
arch: '-arm64',
|
arch: 'arm64',
|
||||||
'version-file': 'latest-linux-arm64.yml'
|
'version-file': 'latest-linux-arm64.yml'
|
||||||
}, {
|
}, {
|
||||||
appNameWithPrefix: 'PicGo-',
|
appNameWithPrefix: 'PicGo',
|
||||||
ext: '.deb',
|
ext: 'deb',
|
||||||
arch: 'amd64',
|
arch: 'amd64',
|
||||||
'version-file': 'latest-linux.yml'
|
'version-file': 'latest-linux.yml'
|
||||||
}, {
|
}, {
|
||||||
appNameWithPrefix: 'PicGo-',
|
appNameWithPrefix: 'PicGo',
|
||||||
ext: '.snap',
|
ext: 'snap',
|
||||||
arch: 'amd64',
|
arch: 'amd64',
|
||||||
'version-file': 'latest-linux.yml'
|
'version-file': 'latest-linux.yml'
|
||||||
}]
|
}]
|
||||||
|
|
||||||
// windows (nsis, x64 + ia32 + arm64)
|
// windows (nsis, x64 + ia32 + arm64)
|
||||||
const win32 = [{
|
const win32 = [{
|
||||||
appNameWithPrefix: 'PicGo-',
|
appNameWithPrefix: 'PicGo',
|
||||||
ext: '.exe',
|
ext: 'exe',
|
||||||
arch: '-ia32',
|
arch: 'ia32',
|
||||||
'version-file': 'latest.yml'
|
'version-file': 'latest.yml'
|
||||||
}, {
|
}, {
|
||||||
appNameWithPrefix: 'PicGo-',
|
appNameWithPrefix: 'PicGo',
|
||||||
ext: '.exe',
|
ext: 'exe',
|
||||||
arch: '-x64',
|
arch: 'x64',
|
||||||
'version-file': 'latest.yml'
|
'version-file': 'latest.yml'
|
||||||
}, {
|
}, {
|
||||||
appNameWithPrefix: 'PicGo-',
|
appNameWithPrefix: 'PicGo',
|
||||||
ext: '.exe',
|
ext: 'exe',
|
||||||
arch: '-arm64',
|
arch: 'arm64',
|
||||||
'version-file': 'latest.yml'
|
'version-file': 'latest.yml'
|
||||||
}]
|
}]
|
||||||
|
|
||||||
|
|||||||
+32
-1
@@ -17,12 +17,16 @@ const Upload = require('@aws-sdk/lib-storage').Upload
|
|||||||
// const COS_SECRET_KEY = process.env.PICGO_ENV_COS_SECRET_KEY
|
// const COS_SECRET_KEY = process.env.PICGO_ENV_COS_SECRET_KEY
|
||||||
|
|
||||||
const S3_BUCKET = 'release'
|
const S3_BUCKET = 'release'
|
||||||
|
const S3_LEGACY_BUCKET = 'picgo'
|
||||||
// const AREA = 'ap-chengdu'
|
// const AREA = 'ap-chengdu'
|
||||||
const VERSION = pkg.version
|
const VERSION = pkg.version
|
||||||
const FILE_PATH = `${VERSION}/`
|
const FILE_PATH = `${VERSION}/`
|
||||||
const S3_SECRET_ID = process.env.PICGO_ENV_S3_SECRET_ID
|
const S3_SECRET_ID = process.env.PICGO_ENV_S3_SECRET_ID
|
||||||
const S3_SECRET_KEY = process.env.PICGO_ENV_S3_SECRET_KEY
|
const S3_SECRET_KEY = process.env.PICGO_ENV_S3_SECRET_KEY
|
||||||
const S3_ACCOUNT_ID = process.env.PICGO_ENV_S3_ACCOUNT_ID
|
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 = {
|
const S3Options = {
|
||||||
credentials: {
|
credentials: {
|
||||||
@@ -34,6 +38,17 @@ const S3Options = {
|
|||||||
region: 'auto'
|
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
|
// https://cloud.tencent.com/document/product/436/7778#signature
|
||||||
// /**
|
// /**
|
||||||
// * @param {string} fileName
|
// * @param {string} fileName
|
||||||
@@ -119,13 +134,14 @@ const uploadDist = async () => {
|
|||||||
if (configList[platform]) {
|
if (configList[platform]) {
|
||||||
const uploadedVersionFiles = new Set()
|
const uploadedVersionFiles = new Set()
|
||||||
for (const [index, config] of configList[platform].entries()) {
|
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 filePath = path.join(distPath, fileName)
|
||||||
const versionFilePath = path.join(distPath, config['version-file'])
|
const versionFilePath = path.join(distPath, config['version-file'])
|
||||||
let versionFileName = config['version-file']
|
let versionFileName = config['version-file']
|
||||||
if (VERSION.toLocaleLowerCase().includes('beta')) {
|
if (VERSION.toLocaleLowerCase().includes('beta')) {
|
||||||
versionFileName = versionFileName.replace('.yml', '.beta.yml')
|
versionFileName = versionFileName.replace('.yml', '.beta.yml')
|
||||||
}
|
}
|
||||||
|
console.log('[PicGo Dist] Preparing to upload', fileName)
|
||||||
const client = new S3Client(S3Options)
|
const client = new S3Client(S3Options)
|
||||||
if (fs.existsSync(filePath)) {
|
if (fs.existsSync(filePath)) {
|
||||||
const uploadDistToS3 = new Upload({
|
const uploadDistToS3 = new Upload({
|
||||||
@@ -143,6 +159,8 @@ const uploadDist = async () => {
|
|||||||
console.log(`[PicGo Dist] Uploading... ${progress.loaded}/${progress.total}`)
|
console.log(`[PicGo Dist] Uploading... ${progress.loaded}/${progress.total}`)
|
||||||
})
|
})
|
||||||
await uploadDistToS3.done()
|
await uploadDistToS3.done()
|
||||||
|
} else {
|
||||||
|
console.warn('[PicGo Dist] File not found:', fileName)
|
||||||
}
|
}
|
||||||
|
|
||||||
// upload version file
|
// upload version file
|
||||||
@@ -156,8 +174,21 @@ const uploadDist = async () => {
|
|||||||
ContentType: mime.lookup(versionFileName)
|
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)
|
console.log('[PicGo Version File] Uploading...', versionFileName)
|
||||||
await uploadVersionFileToS3.done()
|
await uploadVersionFileToS3.done()
|
||||||
|
await uploadVersionFileToLegacyS3.done()
|
||||||
uploadedVersionFiles.add(versionFileName)
|
uploadedVersionFiles.add(versionFileName)
|
||||||
console.log('[PicGo Version File] Upload successfully')
|
console.log('[PicGo Version File] Upload successfully')
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user