chore: aarch script

This commit is contained in:
GyDi 2023-02-01 21:41:15 +08:00
parent b79456e91b
commit 2643e853af
No known key found for this signature in database
GPG Key ID: 9C3AD40F1F99880A

View File

@ -1,12 +1,19 @@
/** /**
* Build and upload assets for macOS(aarch) * Build and upload assets
* for macOS(aarch)
*/ */
import fs from "fs-extra"; import fs from "fs-extra";
import path from "path"; import path from "path";
import { exit } from "process"; import { exit } from "process";
import { execSync } from "child_process";
import { createRequire } from "module"; import { createRequire } from "module";
import { getOctokit, context } from "@actions/github"; import { getOctokit, context } from "@actions/github";
// to `meta` tag
const META = process.argv.includes("--meta");
// to `alpha` tag
const ALPHA = process.argv.includes("--alpha");
const require = createRequire(import.meta.url); const require = createRequire(import.meta.url);
async function resolve() { async function resolve() {
@ -25,6 +32,14 @@ async function resolve() {
const { version } = require("../package.json"); const { version } = require("../package.json");
const tag = META ? "meta" : ALPHA ? "alpha" : `v${version}`;
const buildCmd = META ? `yarn build -f default-meta` : `yarn build`;
console.log(`[INFO]: Upload to tag "${tag}"`);
console.log(`[INFO]: Building app. "${buildCmd}"`);
execSync(buildCmd);
const cwd = process.cwd(); const cwd = process.cwd();
const bundlePath = path.join(cwd, "src-tauri/target/release/bundle"); const bundlePath = path.join(cwd, "src-tauri/target/release/bundle");
const join = (p) => path.join(bundlePath, p); const join = (p) => path.join(bundlePath, p);
@ -48,7 +63,7 @@ async function resolve() {
const { data: release } = await github.rest.repos.getReleaseByTag({ const { data: release } = await github.rest.repos.getReleaseByTag({
...options, ...options,
tag: `v${version}`, tag,
}); });
if (!release.id) throw new Error("failed to find the release"); if (!release.id) throw new Error("failed to find the release");