fix: overwrite native builds if needed (#1186)
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
action: patch
|
||||
---
|
||||
|
||||
Fiixed an issue that caused outdated signatures for macos universal builds in latest.json when re-running the action on the same release multiple times.
|
||||
@@ -15,6 +15,10 @@ jobs:
|
||||
include:
|
||||
- platform: 'macos-latest'
|
||||
args: '--verbose --target universal-apple-darwin --debug'
|
||||
- platform: 'macos-latest'
|
||||
args: '--verbose --target aarch64-apple-darwin --debug'
|
||||
- platform: 'macos-latest'
|
||||
args: '--verbose --target x86_64-apple-darwin --debug'
|
||||
- platform: 'ubuntu-22.04'
|
||||
args: '--verbose --debug'
|
||||
- platform: 'windows-latest'
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+39
-12
@@ -23,6 +23,18 @@ type VersionContent = {
|
||||
};
|
||||
};
|
||||
|
||||
function ghAssetName(
|
||||
artifact: Artifact,
|
||||
releaseAssetNamePattern?: string,
|
||||
): string {
|
||||
return getAssetName(artifact, releaseAssetNamePattern)
|
||||
.trim()
|
||||
.replace(/[ ()[\]{}]/g, '.')
|
||||
.replace(/\.\./g, '.')
|
||||
.normalize('NFD')
|
||||
.replace(/[\u0300-\u036f]/g, '');
|
||||
}
|
||||
|
||||
export async function uploadVersionJSON(
|
||||
owner: string,
|
||||
repo: string,
|
||||
@@ -117,13 +129,24 @@ export async function uploadVersionJSON(
|
||||
|
||||
// Assets matching artifacts generated by this action
|
||||
const filteredAssets = [];
|
||||
// We need to check for these so that we can non-destructively overwrite the relevant json entries with universal builds if needed
|
||||
let hasNativeArm;
|
||||
let hasNativeX64;
|
||||
for (const artifact of artifacts) {
|
||||
const assetName = getAssetName(artifact, releaseAssetNamePattern)
|
||||
.trim()
|
||||
.replace(/[ ()[\]{}]/g, '.')
|
||||
.replace(/\.\./g, '.')
|
||||
.normalize('NFD')
|
||||
.replace(/[\u0300-\u036f]/g, '');
|
||||
if (artifact.ext === '.app.tar.gz' && artifact.arch === 'universal') {
|
||||
const arm = ghAssetName(
|
||||
{ ...artifact, arch: 'aarch64' },
|
||||
releaseAssetNamePattern,
|
||||
);
|
||||
const x86 = ghAssetName(
|
||||
{ ...artifact, arch: 'x86_64' },
|
||||
releaseAssetNamePattern,
|
||||
);
|
||||
hasNativeArm = downloadUrls.has(arm);
|
||||
hasNativeX64 = downloadUrls.has(x86);
|
||||
}
|
||||
|
||||
const assetName = ghAssetName(artifact, releaseAssetNamePattern);
|
||||
const downloadUrl = downloadUrls.get(assetName);
|
||||
if (downloadUrl) {
|
||||
filteredAssets.push({
|
||||
@@ -215,14 +238,16 @@ export async function uploadVersionJSON(
|
||||
// This is our primary updater type we use for `{os}-{arch}`
|
||||
if (idx === 0) {
|
||||
if (os === 'darwin' && arch === 'universal') {
|
||||
// Don't overwrite native builds
|
||||
if (!versionContent.platforms['darwin-aarch64']) {
|
||||
// Don't overwrite native builds unless outdated.
|
||||
// hasNativeArm/x64 can be false while other jobs are overwriting artifacts,
|
||||
// but we should still always end up with a working latest.json file.
|
||||
if (!versionContent.platforms['darwin-aarch64'] || !hasNativeArm) {
|
||||
(versionContent.platforms['darwin-aarch64'] as unknown) = {
|
||||
signature: readFileSync(signatureFile.path).toString(),
|
||||
url: updaterFileDownloadUrl,
|
||||
};
|
||||
}
|
||||
if (!versionContent.platforms['darwin-x86_64']) {
|
||||
if (!versionContent.platforms['darwin-x86_64'] || !hasNativeX64) {
|
||||
(versionContent.platforms['darwin-x86_64'] as unknown) = {
|
||||
signature: readFileSync(signatureFile.path).toString(),
|
||||
url: updaterFileDownloadUrl,
|
||||
@@ -237,14 +262,16 @@ export async function uploadVersionJSON(
|
||||
|
||||
// This is for the new `{os}-{arch}-{installer}` format
|
||||
if (os === 'darwin' && arch === 'universal') {
|
||||
// Don't overwrite native builds
|
||||
if (!versionContent.platforms['darwin-aarch64-app']) {
|
||||
// Don't overwrite native builds unless outdated.
|
||||
// hasNativeArm/x64 can be false while other jobs are overwriting artifacts,
|
||||
// but we should still always end up with a working latest.json file.
|
||||
if (!versionContent.platforms['darwin-aarch64-app'] || !hasNativeArm) {
|
||||
(versionContent.platforms['darwin-aarch64-app'] as unknown) = {
|
||||
signature: readFileSync(signatureFile.path).toString(),
|
||||
url: updaterFileDownloadUrl,
|
||||
};
|
||||
}
|
||||
if (!versionContent.platforms['darwin-x86_64-app']) {
|
||||
if (!versionContent.platforms['darwin-x86_64-app'] || !hasNativeX64) {
|
||||
(versionContent.platforms['darwin-x86_64-app'] as unknown) = {
|
||||
signature: readFileSync(signatureFile.path).toString(),
|
||||
url: updaterFileDownloadUrl,
|
||||
|
||||
@@ -21,7 +21,9 @@ export async function uploadWorkflowArtifacts(
|
||||
if (artifact.ext === '.app') {
|
||||
paths = globbySync('**/*', { cwd: artifact.path, absolute: true });
|
||||
}
|
||||
console.log(JSON.stringify(paths));
|
||||
console.log(
|
||||
"Handing it off to GitHub's uploadArtifact function. This will print a few unmanaged logs.",
|
||||
);
|
||||
await retry(
|
||||
() =>
|
||||
GHArtifact.uploadArtifact(
|
||||
@@ -34,6 +36,7 @@ export async function uploadWorkflowArtifacts(
|
||||
),
|
||||
retryAttempts,
|
||||
);
|
||||
console.log('Workflow artifacts uploads DONE!');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user