fix: correctly handle .app files

This commit is contained in:
Jonas Kruckenberg 2022-05-10 20:13:33 +02:00
parent f62c0ed9bc
commit c9676c7bb6
No known key found for this signature in database
GPG Key ID: 21AD3B3C266BDE3D
2 changed files with 23 additions and 3 deletions

View File

@ -0,0 +1,5 @@
---
"tauri-build": patch
---
Correctly compress .app files or omit them.

View File

@ -1,5 +1,5 @@
import {run} from '@tauri-apps/cli'
import {dirname, join, posix, resolve, sep} from 'path'
import {basename, dirname, join, posix, resolve, sep} from 'path'
import glob from 'tiny-glob'
import * as core from '@actions/core'
import {
@ -66,7 +66,22 @@ export async function buildProject(options: BuildOptions): Promise<string[]> {
core.debug(`Looking for artifacts using this pattern: ${artifactsLookupPattern}`)
return glob(artifactsLookupPattern, { absolute: true, filesOnly: false })
const artifacts = await glob(artifactsLookupPattern, { absolute: true, filesOnly: false })
let i = 0;
for (const artifact of artifacts) {
if (artifact.endsWith('.app') && !artifacts.some(a => a.endsWith('.app.tar.gz'))) {
await execCmd('tar', ['czf', `${artifact}.tar.gz`, '-C', dirname(artifact), basename(artifact)])
artifacts[i] += '.tar.gz'
} else if (artifact.endsWith('.app')) {
// we can't upload a directory
artifacts.splice(i, 1);
}
i++
}
return artifacts
}
async function spawnCmd(
@ -94,7 +109,7 @@ async function spawnCmd(
async function execCmd(
cmd: string,
args: string[],
options: Omit<ExecOptionsWithStringEncoding, 'encoding'>
options: Omit<ExecOptionsWithStringEncoding, 'encoding'> = {}
): Promise<string> {
return new Promise((resolve, reject) => {
exec(