Skip to content

Commit

Permalink
fix: updater file name with spaces and v2 sig files (#845)
Browse files Browse the repository at this point in the history
* Fix updater file name with spaces in them

* Add change file

* Update to new tauri updater config format

* Add pubkey to ci

* Replace ..

* Include v2 sig files

* Update change file

* assetName not path 😅

* missing another AppImage.sig
  • Loading branch information
Legend-Master authored Jul 2, 2024
1 parent 337126f commit 621de48
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 28 deletions.
5 changes: 5 additions & 0 deletions .changes/space-in-updater.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
action: patch
---

Fix can't find updater file name with spaces in them and can't pick up unzipped updater signatures
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
},
"bundle": {
"active": true,
"createUpdaterArtifacts": true,
"targets": "all",
"icon": [
"icons/32x32.png",
Expand All @@ -27,5 +28,10 @@
"icons/icon.icns",
"icons/icon.ico"
]
},
"plugins": {
"updater": {
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDE5QzMxNjYwNTM5OEUwNTgKUldSWTRKaFRZQmJER1h4d1ZMYVA3dnluSjdpN2RmMldJR09hUFFlZDY0SlFqckkvRUJhZDJVZXAK"
}
}
}
8 changes: 4 additions & 4 deletions dist/index.js

Large diffs are not rendered by default.

30 changes: 22 additions & 8 deletions src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,14 @@ export async function buildProject(
artifactsPath,
`bundle/msi/${app.name}_${app.wixAppVersion}_${arch}_${lang}.msi`,
),
);
winArtifacts.push(
join(
artifactsPath,
`bundle/msi/${app.name}_${app.wixAppVersion}_${arch}_${lang}.msi.sig`,
),
join(
artifactsPath,
`bundle/msi/${app.name}_${app.wixAppVersion}_${arch}_${lang}.msi.zip`,
),
);
winArtifacts.push(
join(
artifactsPath,
`bundle/msi/${app.name}_${app.wixAppVersion}_${arch}_${lang}.msi.zip.sig`,
Expand All @@ -147,14 +147,14 @@ export async function buildProject(
artifactsPath,
`bundle/nsis/${app.name}_${app.version}_${arch}-setup.exe`,
),
);
winArtifacts.push(
join(
artifactsPath,
`bundle/nsis/${app.name}_${app.version}_${arch}-setup.exe.sig`,
),
join(
artifactsPath,
`bundle/nsis/${app.name}_${app.version}_${arch}-setup.nsis.zip`,
),
);
winArtifacts.push(
join(
artifactsPath,
`bundle/nsis/${app.name}_${app.version}_${arch}-setup.nsis.zip.sig`,
Expand Down Expand Up @@ -217,6 +217,13 @@ export async function buildProject(
),
arch: appImageArch,
},
{
path: join(
artifactsPath,
`bundle/appimage/${app.name}_${app.version}_${appImageArch}.AppImage.sig`,
),
arch: appImageArch,
},
{
path: join(
artifactsPath,
Expand Down Expand Up @@ -256,6 +263,13 @@ export async function buildProject(
),
arch: appImageArch,
},
{
path: join(
artifactsPath,
`bundle/appimage/${linuxFileAppName}_${app.version}_${appImageArch}.AppImage.sig`,
),
arch: appImageArch,
},
{
path: join(
artifactsPath,
Expand Down
47 changes: 31 additions & 16 deletions src/upload-version-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,31 @@ export async function uploadVersionJSON({
).platforms;
}

const signatureFiles = artifacts.filter((artifact) => {
return artifact.path.endsWith('.sig');
const downloadUrls = new Map<string, string>();
for (const data of assets.data) {
downloadUrls.set(data.name, data.browser_download_url);
}

// Assets matching artifacts generated by this action
const filteredAssets = [];
for (const artifact of artifacts) {
const assetName = getAssetName(artifact.path)
.trim()
.replace(/[ ()[\]{}]/g, '.')
.replace(/\.\./g, '.');
const downloadUrl = downloadUrls.get(assetName);
if (downloadUrl) {
filteredAssets.push({
downloadUrl,
assetName,
path: artifact.path,
arch: artifact.arch,
});
}
}

const signatureFiles = filteredAssets.filter((asset) => {
return asset.assetName.endsWith('.sig');
});
function signaturePriority(signaturePath: string) {
const priorities = updaterJsonPreferNsis
Expand All @@ -115,21 +138,13 @@ export async function uploadVersionJSON({
return;
}

// Assets matching artifacts generated by this action
const assetNames = new Set(
artifacts.map((p) =>
getAssetName(p.path)
.trim()
.replace(/[ ()[\]{}]/g, '.'),
), // GitHub replaces spaces and special chars in asset names with dots
);
const filteredAssets = assets.data.filter((data) =>
assetNames.has(data.name),
const updaterName = basename(
signatureFile.assetName,
extname(signatureFile.assetName),
);
const baseName = basename(signatureFile.path, extname(signatureFile.path));
let downloadUrl = filteredAssets.find((asset) =>
asset.browser_download_url.endsWith(baseName),
)?.browser_download_url;
let downloadUrl = filteredAssets.find(
(asset) => asset.assetName == updaterName,
)?.downloadUrl;
if (!downloadUrl) {
console.warn('Asset not found for the updater JSON. Skipping upload...');
return;
Expand Down

0 comments on commit 621de48

Please sign in to comment.