mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-05-06 20:42:57 +08:00
✨ Feature(custom): optimize auto-upload pipeline
This commit is contained in:
17
.github/workflows/buid_arch.yml
vendored
17
.github/workflows/buid_arch.yml
vendored
@@ -183,10 +183,27 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
echo "Publishing argument: $PUBLISH_ARG"
|
echo "Publishing argument: $PUBLISH_ARG"
|
||||||
if [[ "${{ matrix.os }}" == windows* ]]; then
|
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
|
yarn run build:win ${{ matrix.format}} --${{ matrix.arch }} --publish $PUBLISH_ARG
|
||||||
elif [[ "${{ matrix.os }}" == macos* ]]; then
|
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
|
yarn run build:mac ${{ matrix.format}} --${{ matrix.arch }} --publish $PUBLISH_ARG
|
||||||
elif [[ "${{ matrix.os }}" == ubuntu* ]]; then
|
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
|
yarn run build:linux ${{ matrix.format}} --${{ matrix.arch }} --publish $PUBLISH_ARG
|
||||||
else
|
else
|
||||||
echo "Unsupported OS: ${{ matrix.os }}"
|
echo "Unsupported OS: ${{ matrix.os }}"
|
||||||
|
|||||||
@@ -18,21 +18,9 @@ async function main(context) {
|
|||||||
const portablePath = path.join(appOutDir, 'PORTABLE')
|
const portablePath = path.join(appOutDir, 'PORTABLE')
|
||||||
try {
|
try {
|
||||||
fs.writeFileSync(portablePath, '')
|
fs.writeFileSync(portablePath, '')
|
||||||
console.log('Created portable marker file at', portablePath)
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Error creating portable marker file:', 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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { BrowserWindow, shell } from 'electron'
|
|||||||
import updater from 'electron-updater'
|
import updater from 'electron-updater'
|
||||||
|
|
||||||
import { RPCRouter } from '~/events/rpc/router'
|
import { RPCRouter } from '~/events/rpc/router'
|
||||||
|
import { downloadAndInstallUpdate } from '~/lifeCycle/autoUpdater'
|
||||||
import { configPaths } from '~/utils/configPaths'
|
import { configPaths } from '~/utils/configPaths'
|
||||||
import { IRPCActionType } from '~/utils/enum'
|
import { IRPCActionType } from '~/utils/enum'
|
||||||
|
|
||||||
@@ -15,6 +16,8 @@ const updaterRoutes = [
|
|||||||
handler: async () => {
|
handler: async () => {
|
||||||
if (!isPortable()) {
|
if (!isPortable()) {
|
||||||
updater.autoUpdater.downloadUpdate()
|
updater.autoUpdater.downloadUpdate()
|
||||||
|
} else {
|
||||||
|
downloadAndInstallUpdate()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -130,24 +130,26 @@ export async function setupAutoUpdater() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function checkUpdateAndNotify(): Promise<void> {
|
export async function checkUpdateAndNotify(): Promise<void> {
|
||||||
const url = 'https://release.piclist.cn/latest/latest.yml'
|
if (isPortable()) {
|
||||||
const res = await axios.get(url, {
|
const url = 'https://release.piclist.cn/latest/latest.yml'
|
||||||
headers: { 'Content-Type': 'application/octet-stream' },
|
const res = await axios.get(url, {
|
||||||
responseType: 'text',
|
headers: { 'Content-Type': 'application/octet-stream' },
|
||||||
})
|
responseType: 'text',
|
||||||
const latest = yaml.parseDocument(res.data).toJSON() as unknown as updater.UpdateInfo
|
})
|
||||||
const currentVersion = pkg.version
|
const latest = yaml.parseDocument(res.data).toJSON() as unknown as updater.UpdateInfo
|
||||||
if (latest.version !== currentVersion) {
|
const currentVersion = pkg.version
|
||||||
newVersion = latest.version
|
if (latest.version !== currentVersion) {
|
||||||
updateAvailableHandler(latest)
|
newVersion = latest.version
|
||||||
|
updateAvailableHandler(latest)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function downloadAndInstallUpdate(): Promise<void> {
|
export async function downloadAndInstallUpdate(): Promise<void> {
|
||||||
const baseUrl = 'https://release.piclist.cn/latest'
|
const baseUrl = 'https://release.piclist.cn/latest'
|
||||||
const fileMap = {
|
const fileMap = {
|
||||||
'win32-x64': `PicList-Setup-${newVersion.replace(/^v/, '')}-x64-portable.zip`,
|
'win32-x64': `PicList-Setup-${newVersion.replace(/^v/, '')}-x64-portable.7z`,
|
||||||
'win32-arm64': `PicList-Setup-${newVersion.replace(/^v/, '')}-arm64-portable.zip`,
|
'win32-arm64': `PicList-Setup-${newVersion.replace(/^v/, '')}-arm64-portable.7z`,
|
||||||
} as Record<string, string>
|
} as Record<string, string>
|
||||||
const file = fileMap[`${process.platform}-${process.arch}`]
|
const file = fileMap[`${process.platform}-${process.arch}`]
|
||||||
if (!file) {
|
if (!file) {
|
||||||
@@ -191,8 +193,9 @@ export async function downloadAndInstallUpdate(): Promise<void> {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
progressHandler({ percent: 100 } as updater.ProgressInfo)
|
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'))
|
await fs.copyFile(zipFilePath, path.join(defaultDir(), '7za.exe'))
|
||||||
|
logger.info('Starting update installation...')
|
||||||
spawn(
|
spawn(
|
||||||
'cmd',
|
'cmd',
|
||||||
[
|
[
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import picgo from '@core/picgo'
|
|||||||
import updater from 'electron-updater'
|
import updater from 'electron-updater'
|
||||||
|
|
||||||
import { isPortable } from '~/apis/core/datastore/dirs'
|
import { isPortable } from '~/apis/core/datastore/dirs'
|
||||||
import { downloadAndInstallUpdate } from '~/lifeCycle/autoUpdater'
|
import { checkUpdateAndNotify } from '~/lifeCycle/autoUpdater'
|
||||||
import { configPaths } from '~/utils/configPaths'
|
import { configPaths } from '~/utils/configPaths'
|
||||||
|
|
||||||
const updateChecker = async () => {
|
const updateChecker = async () => {
|
||||||
@@ -16,7 +16,7 @@ const updateChecker = async () => {
|
|||||||
if (!isPortable()) {
|
if (!isPortable()) {
|
||||||
await updater.autoUpdater.checkForUpdatesAndNotify()
|
await updater.autoUpdater.checkForUpdatesAndNotify()
|
||||||
} else {
|
} else {
|
||||||
await downloadAndInstallUpdate()
|
await checkUpdateAndNotify()
|
||||||
}
|
}
|
||||||
} catch (_err) {}
|
} catch (_err) {}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user