🐛 fix(actions): release building
Signed-off-by: Pauline <git@ethanlibs.co>
This commit is contained in:
parent
986bf51e2e
commit
9b57bc1f24
7 changed files with 50 additions and 127132 deletions
127105
.github/actions/publish-artifacts/dist/index.js
generated
vendored
127105
.github/actions/publish-artifacts/dist/index.js
generated
vendored
File diff suppressed because one or more lines are too long
|
|
@ -12,7 +12,7 @@
|
|||
"bugs": "https://github.com/polyfrost/onelauncher/issues",
|
||||
"sideEffects": false,
|
||||
"scripts": {
|
||||
"build": "ncc build src/index.ts"
|
||||
"build": "ncc build src/index.ts --minify"
|
||||
},
|
||||
"dependencies": {
|
||||
"@actions/artifact": "^2.1.9",
|
||||
|
|
|
|||
19
.github/actions/publish-artifacts/src/index.ts
vendored
19
.github/actions/publish-artifacts/src/index.ts
vendored
|
|
@ -1,3 +1,4 @@
|
|||
import process from 'node:process';
|
||||
import client from '@actions/artifact';
|
||||
import core from '@actions/core';
|
||||
import glob from '@actions/glob';
|
||||
|
|
@ -7,6 +8,7 @@ import { exists } from '@actions/io/lib/io-util';
|
|||
type OS = 'darwin' | 'windows' | 'linux';
|
||||
type Arch = 'x64' | 'arm64';
|
||||
type Profile = 'debug' | 'release' | 'dev' | 'dev-debug';
|
||||
|
||||
interface Updater {
|
||||
bundle: string;
|
||||
bundleExt: string;
|
||||
|
|
@ -18,7 +20,7 @@ interface TargetConfig {
|
|||
}
|
||||
interface BuildTarget {
|
||||
updater: false | Updater;
|
||||
standalone: Array<TargetConfig>;
|
||||
standalone: TargetConfig[];
|
||||
}
|
||||
|
||||
const osTargets = {
|
||||
|
|
@ -71,7 +73,11 @@ async function uploadFrontend() {
|
|||
return;
|
||||
}
|
||||
|
||||
await client.uploadArtifact(frontendName, [frontendBundle], 'apps/frontend');
|
||||
const artifactName = `${frontendName}.tar.xz`;
|
||||
const artifactPath = `${artifactsDir}/${artifactName}`;
|
||||
|
||||
await io.cp(frontendBundle, artifactPath);
|
||||
await client.uploadArtifact(artifactName, [artifactPath], artifactsDir);
|
||||
}
|
||||
|
||||
async function uploadUpdater(updater: BuildTarget['updater']) {
|
||||
|
|
@ -84,7 +90,7 @@ async function uploadUpdater(updater: BuildTarget['updater']) {
|
|||
const updaterPath = files.find(f => f.endsWith(fullExt));
|
||||
|
||||
if (!updaterPath)
|
||||
throw new Error(`failed to find updater path in ${files}`);
|
||||
throw new Error(`failed to find updater path in ${files.join(',')}`);
|
||||
|
||||
const artifactPath = `${artifactsDir}/${updaterName}.${archiveExt}`;
|
||||
await io.cp(updaterPath, artifactPath);
|
||||
|
|
@ -97,7 +103,7 @@ async function uploadStandalone({ bundle, ext }: TargetConfig) {
|
|||
const standalonePath = files.find(f => f.endsWith(ext));
|
||||
|
||||
if (!standalonePath)
|
||||
throw new Error(`failed to find standalone path in ${files}`);
|
||||
throw new Error(`failed to find standalone path in ${files.join(',')}`);
|
||||
|
||||
const artifactName = `${artifactBase}.${ext}`;
|
||||
const artifactPath = `${artifactsDir}/${artifactName}`;
|
||||
|
|
@ -116,4 +122,7 @@ async function run() {
|
|||
]);
|
||||
}
|
||||
|
||||
run();
|
||||
run().catch((error) => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
});
|
||||
|
|
|
|||
7
.github/workflows/release.yml
vendored
7
.github/workflows/release.yml
vendored
|
|
@ -4,6 +4,7 @@ on:
|
|||
pull_request:
|
||||
paths:
|
||||
- .github/workflows/release.yml
|
||||
- .github/actions/publish-artifacts/**
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
|
|
@ -18,12 +19,12 @@ jobs:
|
|||
settings:
|
||||
- host: macos-13
|
||||
target: x86_64-apple-darwin
|
||||
bundles: app,dmg
|
||||
bundles: dmg,app
|
||||
os: darwin
|
||||
arch: x86_64
|
||||
- host: macos-14
|
||||
target: aarch64-apple-darwin
|
||||
bundles: app,dmg
|
||||
bundles: dmg,app
|
||||
os: darwin
|
||||
arch: aarch64
|
||||
- host: windows-latest
|
||||
|
|
@ -90,7 +91,7 @@ jobs:
|
|||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Build
|
||||
run: pnpm desktop build --ci -v --target ${{ matrix.settings.target }} --bundles ${{ matrix.settings.bundles }},updater
|
||||
run: pnpm desktop build --ci -v --target ${{ matrix.settings.target }} --bundles ${{ matrix.settings.bundles }}
|
||||
# env:
|
||||
# TAURI_SIGNING_PRIVATE_KEY: $ {{ secrets.TAURI_PRIVATE_KEY }}
|
||||
# TAURI_SIGNING_PRIVATE_KEY_PASSWORD: $ {{ secrets.TAURI_KEY_PASSWORD }}
|
||||
|
|
|
|||
|
|
@ -107,6 +107,7 @@
|
|||
"license": "GPL-3.0-only",
|
||||
"homepage": "https://polyfrost.org/",
|
||||
"longDescription": "Next-generation open source Minecraft launcher",
|
||||
"createUpdaterArtifacts": true,
|
||||
"resources": [],
|
||||
"externalBin": [],
|
||||
"linux": {
|
||||
|
|
@ -120,6 +121,17 @@
|
|||
"entitlements": "App.entitlements",
|
||||
"exceptionDomain": null,
|
||||
"frameworks": [],
|
||||
"dmg": {
|
||||
"background": "../../packages/distribution/macos/dmg-background.png",
|
||||
"appPosition": {
|
||||
"x": 190,
|
||||
"y": 190
|
||||
},
|
||||
"applicationFolderPosition": {
|
||||
"x": 470,
|
||||
"y": 190
|
||||
}
|
||||
},
|
||||
"providerShortName": null,
|
||||
"signingIdentity": null,
|
||||
"minimumSystemVersion": "10.15"
|
||||
|
|
@ -136,8 +148,6 @@
|
|||
},
|
||||
"plugins": {
|
||||
"updater": {
|
||||
"active": true,
|
||||
"dialog": false,
|
||||
"pubkey": "",
|
||||
"endpoints": ["https://polyfrost.org/releases/tauri/{{version}}/{{target}}/{{arch}}"]
|
||||
},
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ const __desktop = pathe.join(__root, 'apps', 'desktop');
|
|||
const __cleanup: string[] = [];
|
||||
|
||||
const cleanup = () => Promise.all(__cleanup.map(f => fs.unlink(f).catch((_) => {})));
|
||||
const exists = (path: string) => fs.access(path, fs.constants.R_OK).then(_ => true).catch(_ => false);
|
||||
|
||||
process.on('SIGINT', cleanup);
|
||||
if (args.length === 0)
|
||||
|
|
@ -38,7 +37,7 @@ const store = { code: 0 };
|
|||
try {
|
||||
switch (args[0]) {
|
||||
case 'dev': {
|
||||
__cleanup.push(...(await patchTauri(env, targets, bundles, args)));
|
||||
__cleanup.push(...(await patchTauri(env, targets, args)));
|
||||
switch (process.platform) {
|
||||
case 'linux':
|
||||
case 'darwin':
|
||||
|
|
@ -54,18 +53,7 @@ try {
|
|||
process.env.NODE_OPTIONS = `--max_old_space_size=4096 ${process.env.NODE_OPTIONS ?? ''}`;
|
||||
|
||||
process.env.GENERATE_SOURCEMAP = 'false';
|
||||
__cleanup.push(...(await patchTauri(env, targets, bundles, args)));
|
||||
|
||||
if (process.platform === 'darwin') {
|
||||
process.env.BACKGROUND_FILE = pathe.resolve(__distribution, 'macos', 'dmg.png');
|
||||
process.env.BACKGROUND_FILE_NAME = pathe.basename(process.env.BACKGROUND_FILE);
|
||||
process.env.BACKGROUND_CLAUSE = `set background picture of opts to file ".background:${process.env.BACKGROUND_FILE_NAME}"`;
|
||||
|
||||
if (!(await exists(process.env.BACKGROUND_FILE)))
|
||||
console.warn(`dmg background file not found at ${process.env.BACKGROUND_FILE}`);
|
||||
|
||||
break;
|
||||
}
|
||||
__cleanup.push(...(await patchTauri(env, targets, args)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,12 +41,7 @@ export async function tauriUpdateKey(env: CheckedEnvironment): Promise<string |
|
|||
return keys.publicKey;
|
||||
}
|
||||
|
||||
export async function patchTauri(
|
||||
env: CheckedEnvironment,
|
||||
targets: string[],
|
||||
bundles: string[],
|
||||
args: string[],
|
||||
): Promise<string[]> {
|
||||
export async function patchTauri(env: CheckedEnvironment, targets: string[], args: string[]): Promise<string[]> {
|
||||
if (args.findIndex(a => ['-c', '--config'].includes(a)) !== -1)
|
||||
throw new Error('custom tauri build configuration is not supported!');
|
||||
|
||||
|
|
@ -75,31 +70,23 @@ export async function patchTauri(
|
|||
|
||||
const tauriRoot = join(env.__root, 'apps', 'desktop');
|
||||
const tauriConfig = JSON.parse(await fs.readFile(join(tauriRoot, 'tauri.conf.json'), 'utf-8'));
|
||||
if (bundles.length === 0) {
|
||||
const defaultBundles = tauriConfig?.bundle?.targets;
|
||||
if (Array.isArray(defaultBundles))
|
||||
bundles.push(...defaultBundles);
|
||||
if (bundles.length === 0)
|
||||
bundles.push('all');
|
||||
}
|
||||
|
||||
switch (args[0]) {
|
||||
case 'dev':
|
||||
tauriPatch.build.features.push('devtools');
|
||||
break;
|
||||
case 'build':
|
||||
if (tauriConfig.plugins?.updater?.active) {
|
||||
if (tauriConfig.bundle?.createUpdaterArtifacts !== false) {
|
||||
const pubKey = await tauriUpdateKey(env);
|
||||
if (pubKey != null)
|
||||
tauriPatch.plugins.updater.pubkey = pubKey;
|
||||
}
|
||||
// tauriPatch.build.features.push('devtools');
|
||||
break;
|
||||
}
|
||||
|
||||
if (osType === 'Darwin') {
|
||||
const macOSStore = {
|
||||
defaultArm64: '11.0',
|
||||
defaultArm64: '11.0', // arm64 support was added in macOS 11.0
|
||||
minimumVersion: tauriConfig?.bundle?.macOS?.minimumSystemVersion,
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue