chore(ci): windows auto updater file not uploaded & failed to merge macos files
This commit is contained in:
@@ -317,6 +317,10 @@ jobs:
|
||||
if: ${{ github.event_name == 'release' }}
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
# Possible auto updater files:
|
||||
# Windows: latest.yml
|
||||
# macOS: latest-mac.yml (arm64), latest-mac.yml (x64)
|
||||
# Linux: latest-linux-arm64.yml (arm64), latest-linux.yml (x64)
|
||||
files: |
|
||||
apps/stage-tamagotchi/bundle/${{ env.PRODUCT_NAME }}-*.exe
|
||||
apps/stage-tamagotchi/bundle/${{ env.PRODUCT_NAME }}-*.zip
|
||||
@@ -324,6 +328,7 @@ jobs:
|
||||
apps/stage-tamagotchi/bundle/${{ env.PRODUCT_NAME }}-*.deb
|
||||
apps/stage-tamagotchi/bundle/${{ env.PRODUCT_NAME }}-*.rpm
|
||||
apps/stage-tamagotchi/bundle/${{ env.PRODUCT_NAME }}-*.flatpak
|
||||
apps/stage-tamagotchi/bundle/latest.yml
|
||||
apps/stage-tamagotchi/bundle/latest-*.yml
|
||||
append_body: true
|
||||
|
||||
@@ -364,8 +369,7 @@ jobs:
|
||||
- name: Merge latest-mac.yml
|
||||
run: |
|
||||
pnpm -F @proj-airi/stage-tamagotchi exec tsx scripts/merge-latest-mac.ts \
|
||||
--input artifacts/x64/latest-mac.yml \
|
||||
--input artifacts/arm64/latest-mac.yml \
|
||||
--dir artifacts \
|
||||
--output apps/stage-tamagotchi/bundle/latest-mac.yml
|
||||
|
||||
- name: Upload merged latest-mac.yml
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { existsSync, readdirSync } from 'node:fs'
|
||||
import { existsSync, readdirSync, statSync } from 'node:fs'
|
||||
import { mkdir, readFile, writeFile } from 'node:fs/promises'
|
||||
import { dirname, resolve } from 'node:path'
|
||||
import { exit } from 'node:process'
|
||||
@@ -78,6 +78,22 @@ async function readUpdateInfo(filePath: string): Promise<UpdateInfo> {
|
||||
return yaml.parse(raw) as UpdateInfo
|
||||
}
|
||||
|
||||
function collectLatestMacFiles(rootDir: string): string[] {
|
||||
const results: string[] = []
|
||||
const entries = readdirSync(rootDir, { withFileTypes: true })
|
||||
for (const entry of entries) {
|
||||
const fullPath = resolve(rootDir, entry.name)
|
||||
if (entry.isDirectory()) {
|
||||
results.push(...collectLatestMacFiles(fullPath))
|
||||
continue
|
||||
}
|
||||
if (entry.isFile() && entry.name.startsWith('latest-mac') && entry.name.endsWith('.yml')) {
|
||||
results.push(fullPath)
|
||||
}
|
||||
}
|
||||
return results
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const cli = cac('merge-latest-mac')
|
||||
.option('--input <path>', 'Input latest-mac yml file', { default: [], type: [String] })
|
||||
@@ -90,16 +106,25 @@ async function main() {
|
||||
|
||||
let files: string[] = []
|
||||
if (inputs.length > 0) {
|
||||
files = inputs.map(file => resolve(file))
|
||||
for (const input of inputs) {
|
||||
const resolved = resolve(input)
|
||||
if (!existsSync(resolved)) {
|
||||
continue
|
||||
}
|
||||
if (statSync(resolved).isDirectory()) {
|
||||
files.push(...collectLatestMacFiles(resolved))
|
||||
}
|
||||
else {
|
||||
files.push(resolved)
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
const scanDir = dir || resolve('bundle')
|
||||
const candidates = readdirSync(scanDir).filter(
|
||||
file => file.startsWith('latest-mac') && file.endsWith('.yml'),
|
||||
)
|
||||
files = candidates.map(file => resolve(scanDir, file))
|
||||
files = collectLatestMacFiles(scanDir)
|
||||
}
|
||||
|
||||
console.info('merge-latest-mac: found candidates', files)
|
||||
if (files.length === 0) {
|
||||
throw new Error('No latest-mac*.yml files found')
|
||||
}
|
||||
@@ -107,10 +132,12 @@ async function main() {
|
||||
const entries: { filePath: string, updateInfo: UpdateInfo, platform: Platform }[] = []
|
||||
for (const filePath of files) {
|
||||
if (!existsSync(filePath)) {
|
||||
console.warn('merge-latest-mac: missing file', filePath)
|
||||
continue
|
||||
}
|
||||
const updateInfo = await readUpdateInfo(filePath)
|
||||
const platform = detectPlatform(updateInfo)
|
||||
console.info('merge-latest-mac: detected platform', { filePath, platform })
|
||||
entries.push({ filePath, updateInfo, platform })
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user