fix(Updater): fix arch and download link in latest.json generation (#328)

* fix: updater download urls

* fix: set arch correctly

* fix: build new action

* fix: error when downloadUrl is undefined
This commit is contained in:
solvedDev
2022-11-25 22:54:11 +01:00
committed by GitHub
parent 774d52fa00
commit 23aa62fe6e
3 changed files with 21 additions and 12 deletions

File diff suppressed because one or more lines are too long

View File

@@ -127,6 +127,7 @@ async function run(): Promise<void> {
await uploadVersionJSON({
version: info.version,
notes: body,
tagName,
releaseId,
artifacts
})

View File

@@ -10,11 +10,13 @@ import { Artifact } from '@tauri-apps/action-core'
export default async function uploadVersionJSON({
version,
notes,
tagName,
releaseId,
artifacts
}: {
version: string
notes: string
tagName: string
releaseId: number
artifacts: Artifact[]
}) {
@@ -71,26 +73,32 @@ export default async function uploadVersionJSON({
const sigFile = artifacts.find((s) => s.path.endsWith('.sig'))
const assetNames = new Set(artifacts.map((p) => getAssetName(p.path)))
const downloadUrl = assets.data
let downloadUrl = assets.data
.filter((e) => assetNames.has(e.name))
.find(
(s) => s.name.endsWith('.tar.gz') || s.name.endsWith('.zip')
)?.browser_download_url
// Untagged release downloads won't work after the release was published
downloadUrl = downloadUrl?.replace(
/\/download\/(untagged-[^\/]+)\//,
`/download/${tagName}/`
)
let os = platform() as string
if (os === 'win32') os = 'windows'
if (downloadUrl && sigFile) {
let arch = sigFile.arch
arch === 'amd64' || arch === 'x86_64' || arch === 'x64'
? 'x86_64'
: arch === 'x86' || arch === 'i386'
? 'i686'
: arch === 'arm'
? 'armv7'
: arch === 'arm64'
? 'aarch64'
: arch
arch =
arch === 'amd64' || arch === 'x86_64' || arch === 'x64'
? 'x86_64'
: arch === 'x86' || arch === 'i386'
? 'i686'
: arch === 'arm'
? 'armv7'
: arch === 'arm64'
? 'aarch64'
: arch
// https://github.com/tauri-apps/tauri/blob/fd125f76d768099dc3d4b2d4114349ffc31ffac9/core/tauri/src/updater/core.rs#L856
versionContent.platforms[`${os}-${arch}`] = {