From 52c88ce6cfcd8e951b027cd1aadba562c93befe7 Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Sun, 12 Jul 2020 15:58:36 -0300 Subject: [PATCH] fix(action) macOS .app compression with `includeDir`= true --- .changes/tar-debug-conflict.md | 5 +++++ dist/index.js | 10 ++++------ src/main.ts | 6 +----- src/upload-release-assets.ts | 4 +++- 4 files changed, 13 insertions(+), 12 deletions(-) create mode 100644 .changes/tar-debug-conflict.md diff --git a/.changes/tar-debug-conflict.md b/.changes/tar-debug-conflict.md new file mode 100644 index 0000000000..4d4c3a7b04 --- /dev/null +++ b/.changes/tar-debug-conflict.md @@ -0,0 +1,5 @@ +--- +"action": patch +--- + +Fixes the macOS `.app` compression to `tar` when using `includeDebug`. diff --git a/dist/index.js b/dist/index.js index edb517f3c6..dfae423da6 100644 --- a/dist/index.js +++ b/dist/index.js @@ -11179,10 +11179,12 @@ function uploadAssets(uploadUrl, assets) { const headers = { 'content-type': 'application/zip', 'content-length': contentLength(assetPath) }; const ext = path_1.default.extname(assetPath); const filename = path_1.default.basename(assetPath).replace(ext, ''); + const assetName = path_1.default.dirname(assetPath).endsWith('debug') ? `${filename}-debug${ext}` : `${filename}${ext}`; + console.log(`Uploading ${assetName}...`); yield github.repos.uploadReleaseAsset({ url: uploadUrl, headers, - name: path_1.default.dirname(assetPath).endsWith('debug') ? `${filename}-debug${ext}` : `${filename}${ext}`, + name: assetName, data: fs_1.default.readFileSync(assetPath) }); } @@ -12380,18 +12382,14 @@ function run() { } if (uploadUrl) { if (os_1.platform() === 'darwin') { - let index = -1; let i = 0; for (const artifact of artifacts) { if (artifact.endsWith('.app')) { - index = i; yield execCommand(`tar -czf ${artifact}.tgz ${artifact}`, { cwd: undefined }); + artifacts[i] += '.tgz'; } i++; } - if (index >= 0) { - artifacts[index] = artifacts[index] + '.tgz'; - } } yield upload_release_assets_1.default(uploadUrl, artifacts); } diff --git a/src/main.ts b/src/main.ts index 5c6b87e924..a6198685e6 100644 --- a/src/main.ts +++ b/src/main.ts @@ -207,18 +207,14 @@ async function run(): Promise { if (uploadUrl) { if (platform() === 'darwin') { - let index = -1 let i = 0 for (const artifact of artifacts) { if (artifact.endsWith('.app')) { - index = i await execCommand(`tar -czf ${artifact}.tgz ${artifact}`, { cwd: undefined }) + artifacts[i] += '.tgz' } i++ } - if (index >= 0) { - artifacts[index] = artifacts[index] + '.tgz' - } } await uploadReleaseAssets(uploadUrl, artifacts) } diff --git a/src/upload-release-assets.ts b/src/upload-release-assets.ts index 0ed748e839..028aadcda7 100644 --- a/src/upload-release-assets.ts +++ b/src/upload-release-assets.ts @@ -17,10 +17,12 @@ export default async function uploadAssets(uploadUrl: string, assets: string[]) const ext = path.extname(assetPath) const filename = path.basename(assetPath).replace(ext, '') + const assetName = path.dirname(assetPath).endsWith('debug') ? `${filename}-debug${ext}` : `${filename}${ext}` + console.log(`Uploading ${assetName}...`) await github.repos.uploadReleaseAsset({ url: uploadUrl, headers, - name: path.dirname(assetPath).endsWith('debug') ? `${filename}-debug${ext}` : `${filename}${ext}`, + name: assetName, data: fs.readFileSync(assetPath) }) }