Feature(custom): optimize auto-upload pipeline

This commit is contained in:
Kuingsmile
2026-01-15 20:49:57 +08:00
parent 842a7a89e6
commit db8dd19eae
5 changed files with 38 additions and 27 deletions

View File

@@ -183,10 +183,27 @@ jobs:
fi
echo "Publishing argument: $PUBLISH_ARG"
if [[ "${{ matrix.os }}" == windows* ]]; then
if [[ "${{ matrix.format }}" == "nsis" ]]; then
rm -f ./resources/7za.exe
if [ -f ./resources/7za.exe ]; then
echo "Error: 7za.exe was not removed from resources."
exit 1
fi
fi
yarn run build:win ${{ matrix.format}} --${{ matrix.arch }} --publish $PUBLISH_ARG
elif [[ "${{ matrix.os }}" == macos* ]]; then
rm -f ./resources/7za.exe
if [ -f ./resources/7za.exe ]; then
echo "Error: 7za.exe was not removed from resources."
exit 1
fi
yarn run build:mac ${{ matrix.format}} --${{ matrix.arch }} --publish $PUBLISH_ARG
elif [[ "${{ matrix.os }}" == ubuntu* ]]; then
rm -f ./resources/7za.exe
if [ -f ./resources/7za.exe ]; then
echo "Error: 7za.exe was not removed from resources."
exit 1
fi
yarn run build:linux ${{ matrix.format}} --${{ matrix.arch }} --publish $PUBLISH_ARG
else
echo "Unsupported OS: ${{ matrix.os }}"

View File

@@ -18,21 +18,9 @@ async function main(context) {
const portablePath = path.join(appOutDir, 'PORTABLE')
try {
fs.writeFileSync(portablePath, '')
console.log('Created portable marker file at', portablePath)
} catch (err) {
console.error('Error creating portable marker file:', err)
}
} else {
const fileToRemave = path.join(appOutDir, 'resources/7za.exe')
console.log('Checking for unnecessary 7za.exe at', fileToRemave)
if (fs.existsSync(fileToRemave)) {
try {
fs.unlinkSync(fileToRemave)
console.log('Removed unnecessary 7za.exe from', fileToRemave)
} catch (err) {
console.error('Error removing 7za.exe:', err)
}
}
}
}

View File

@@ -4,6 +4,7 @@ import { BrowserWindow, shell } from 'electron'
import updater from 'electron-updater'
import { RPCRouter } from '~/events/rpc/router'
import { downloadAndInstallUpdate } from '~/lifeCycle/autoUpdater'
import { configPaths } from '~/utils/configPaths'
import { IRPCActionType } from '~/utils/enum'
@@ -15,6 +16,8 @@ const updaterRoutes = [
handler: async () => {
if (!isPortable()) {
updater.autoUpdater.downloadUpdate()
} else {
downloadAndInstallUpdate()
}
},
},

View File

@@ -130,6 +130,7 @@ export async function setupAutoUpdater() {
}
export async function checkUpdateAndNotify(): Promise<void> {
if (isPortable()) {
const url = 'https://release.piclist.cn/latest/latest.yml'
const res = await axios.get(url, {
headers: { 'Content-Type': 'application/octet-stream' },
@@ -141,13 +142,14 @@ export async function checkUpdateAndNotify(): Promise<void> {
newVersion = latest.version
updateAvailableHandler(latest)
}
}
}
export async function downloadAndInstallUpdate(): Promise<void> {
const baseUrl = 'https://release.piclist.cn/latest'
const fileMap = {
'win32-x64': `PicList-Setup-${newVersion.replace(/^v/, '')}-x64-portable.zip`,
'win32-arm64': `PicList-Setup-${newVersion.replace(/^v/, '')}-arm64-portable.zip`,
'win32-x64': `PicList-Setup-${newVersion.replace(/^v/, '')}-x64-portable.7z`,
'win32-arm64': `PicList-Setup-${newVersion.replace(/^v/, '')}-arm64-portable.7z`,
} as Record<string, string>
const file = fileMap[`${process.platform}-${process.arch}`]
if (!file) {
@@ -191,8 +193,9 @@ export async function downloadAndInstallUpdate(): Promise<void> {
return
}
progressHandler({ percent: 100 } as updater.ProgressInfo)
const zipFilePath = path.join(dirname, '../../../resources/7za.exe').replace('app.asar', 'app.asar.unpacked')
const zipFilePath = path.join(dirname, '../../resources/7za.exe').replace('app.asar', 'app.asar.unpacked')
await fs.copyFile(zipFilePath, path.join(defaultDir(), '7za.exe'))
logger.info('Starting update installation...')
spawn(
'cmd',
[

View File

@@ -2,7 +2,7 @@ import picgo from '@core/picgo'
import updater from 'electron-updater'
import { isPortable } from '~/apis/core/datastore/dirs'
import { downloadAndInstallUpdate } from '~/lifeCycle/autoUpdater'
import { checkUpdateAndNotify } from '~/lifeCycle/autoUpdater'
import { configPaths } from '~/utils/configPaths'
const updateChecker = async () => {
@@ -16,7 +16,7 @@ const updateChecker = async () => {
if (!isPortable()) {
await updater.autoUpdater.checkForUpdatesAndNotify()
} else {
await downloadAndInstallUpdate()
await checkUpdateAndNotify()
}
} catch (_err) {}
}