Skip to content

Commit

Permalink
fix(action) macOS .app compression with includeDir= true
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog committed Jul 12, 2020
1 parent 079b60b commit 52c88ce
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changes/tar-debug-conflict.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"action": patch
---

Fixes the macOS `.app` compression to `tar` when using `includeDebug`.
10 changes: 4 additions & 6 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
});
}
Expand Down Expand Up @@ -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);
}
Expand Down
6 changes: 1 addition & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,18 +207,14 @@ async function run(): Promise<void> {

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)
}
Expand Down
4 changes: 3 additions & 1 deletion src/upload-release-assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
Expand Down

0 comments on commit 52c88ce

Please sign in to comment.