Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: updater file name with spaces and v2 sig files #845

Merged
merged 9 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading