🐛 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",
|
"bugs": "https://github.com/polyfrost/onelauncher/issues",
|
||||||
"sideEffects": false,
|
"sideEffects": false,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "ncc build src/index.ts"
|
"build": "ncc build src/index.ts --minify"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/artifact": "^2.1.9",
|
"@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 client from '@actions/artifact';
|
||||||
import core from '@actions/core';
|
import core from '@actions/core';
|
||||||
import glob from '@actions/glob';
|
import glob from '@actions/glob';
|
||||||
|
|
@ -7,6 +8,7 @@ import { exists } from '@actions/io/lib/io-util';
|
||||||
type OS = 'darwin' | 'windows' | 'linux';
|
type OS = 'darwin' | 'windows' | 'linux';
|
||||||
type Arch = 'x64' | 'arm64';
|
type Arch = 'x64' | 'arm64';
|
||||||
type Profile = 'debug' | 'release' | 'dev' | 'dev-debug';
|
type Profile = 'debug' | 'release' | 'dev' | 'dev-debug';
|
||||||
|
|
||||||
interface Updater {
|
interface Updater {
|
||||||
bundle: string;
|
bundle: string;
|
||||||
bundleExt: string;
|
bundleExt: string;
|
||||||
|
|
@ -18,7 +20,7 @@ interface TargetConfig {
|
||||||
}
|
}
|
||||||
interface BuildTarget {
|
interface BuildTarget {
|
||||||
updater: false | Updater;
|
updater: false | Updater;
|
||||||
standalone: Array<TargetConfig>;
|
standalone: TargetConfig[];
|
||||||
}
|
}
|
||||||
|
|
||||||
const osTargets = {
|
const osTargets = {
|
||||||
|
|
@ -71,7 +73,11 @@ async function uploadFrontend() {
|
||||||
return;
|
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']) {
|
async function uploadUpdater(updater: BuildTarget['updater']) {
|
||||||
|
|
@ -84,7 +90,7 @@ async function uploadUpdater(updater: BuildTarget['updater']) {
|
||||||
const updaterPath = files.find(f => f.endsWith(fullExt));
|
const updaterPath = files.find(f => f.endsWith(fullExt));
|
||||||
|
|
||||||
if (!updaterPath)
|
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}`;
|
const artifactPath = `${artifactsDir}/${updaterName}.${archiveExt}`;
|
||||||
await io.cp(updaterPath, artifactPath);
|
await io.cp(updaterPath, artifactPath);
|
||||||
|
|
@ -97,7 +103,7 @@ async function uploadStandalone({ bundle, ext }: TargetConfig) {
|
||||||
const standalonePath = files.find(f => f.endsWith(ext));
|
const standalonePath = files.find(f => f.endsWith(ext));
|
||||||
|
|
||||||
if (!standalonePath)
|
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 artifactName = `${artifactBase}.${ext}`;
|
||||||
const artifactPath = `${artifactsDir}/${artifactName}`;
|
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:
|
pull_request:
|
||||||
paths:
|
paths:
|
||||||
- .github/workflows/release.yml
|
- .github/workflows/release.yml
|
||||||
|
- .github/actions/publish-artifacts/**
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
env:
|
env:
|
||||||
|
|
@ -18,12 +19,12 @@ jobs:
|
||||||
settings:
|
settings:
|
||||||
- host: macos-13
|
- host: macos-13
|
||||||
target: x86_64-apple-darwin
|
target: x86_64-apple-darwin
|
||||||
bundles: app,dmg
|
bundles: dmg,app
|
||||||
os: darwin
|
os: darwin
|
||||||
arch: x86_64
|
arch: x86_64
|
||||||
- host: macos-14
|
- host: macos-14
|
||||||
target: aarch64-apple-darwin
|
target: aarch64-apple-darwin
|
||||||
bundles: app,dmg
|
bundles: dmg,app
|
||||||
os: darwin
|
os: darwin
|
||||||
arch: aarch64
|
arch: aarch64
|
||||||
- host: windows-latest
|
- host: windows-latest
|
||||||
|
|
@ -90,7 +91,7 @@ jobs:
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Build
|
- 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:
|
# env:
|
||||||
# TAURI_SIGNING_PRIVATE_KEY: $ {{ secrets.TAURI_PRIVATE_KEY }}
|
# TAURI_SIGNING_PRIVATE_KEY: $ {{ secrets.TAURI_PRIVATE_KEY }}
|
||||||
# TAURI_SIGNING_PRIVATE_KEY_PASSWORD: $ {{ secrets.TAURI_KEY_PASSWORD }}
|
# TAURI_SIGNING_PRIVATE_KEY_PASSWORD: $ {{ secrets.TAURI_KEY_PASSWORD }}
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,7 @@
|
||||||
"license": "GPL-3.0-only",
|
"license": "GPL-3.0-only",
|
||||||
"homepage": "https://polyfrost.org/",
|
"homepage": "https://polyfrost.org/",
|
||||||
"longDescription": "Next-generation open source Minecraft launcher",
|
"longDescription": "Next-generation open source Minecraft launcher",
|
||||||
|
"createUpdaterArtifacts": true,
|
||||||
"resources": [],
|
"resources": [],
|
||||||
"externalBin": [],
|
"externalBin": [],
|
||||||
"linux": {
|
"linux": {
|
||||||
|
|
@ -120,6 +121,17 @@
|
||||||
"entitlements": "App.entitlements",
|
"entitlements": "App.entitlements",
|
||||||
"exceptionDomain": null,
|
"exceptionDomain": null,
|
||||||
"frameworks": [],
|
"frameworks": [],
|
||||||
|
"dmg": {
|
||||||
|
"background": "../../packages/distribution/macos/dmg-background.png",
|
||||||
|
"appPosition": {
|
||||||
|
"x": 190,
|
||||||
|
"y": 190
|
||||||
|
},
|
||||||
|
"applicationFolderPosition": {
|
||||||
|
"x": 470,
|
||||||
|
"y": 190
|
||||||
|
}
|
||||||
|
},
|
||||||
"providerShortName": null,
|
"providerShortName": null,
|
||||||
"signingIdentity": null,
|
"signingIdentity": null,
|
||||||
"minimumSystemVersion": "10.15"
|
"minimumSystemVersion": "10.15"
|
||||||
|
|
@ -136,8 +148,6 @@
|
||||||
},
|
},
|
||||||
"plugins": {
|
"plugins": {
|
||||||
"updater": {
|
"updater": {
|
||||||
"active": true,
|
|
||||||
"dialog": false,
|
|
||||||
"pubkey": "",
|
"pubkey": "",
|
||||||
"endpoints": ["https://polyfrost.org/releases/tauri/{{version}}/{{target}}/{{arch}}"]
|
"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: string[] = [];
|
||||||
|
|
||||||
const cleanup = () => Promise.all(__cleanup.map(f => fs.unlink(f).catch((_) => {})));
|
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);
|
process.on('SIGINT', cleanup);
|
||||||
if (args.length === 0)
|
if (args.length === 0)
|
||||||
|
|
@ -38,7 +37,7 @@ const store = { code: 0 };
|
||||||
try {
|
try {
|
||||||
switch (args[0]) {
|
switch (args[0]) {
|
||||||
case 'dev': {
|
case 'dev': {
|
||||||
__cleanup.push(...(await patchTauri(env, targets, bundles, args)));
|
__cleanup.push(...(await patchTauri(env, targets, args)));
|
||||||
switch (process.platform) {
|
switch (process.platform) {
|
||||||
case 'linux':
|
case 'linux':
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
|
|
@ -54,18 +53,7 @@ try {
|
||||||
process.env.NODE_OPTIONS = `--max_old_space_size=4096 ${process.env.NODE_OPTIONS ?? ''}`;
|
process.env.NODE_OPTIONS = `--max_old_space_size=4096 ${process.env.NODE_OPTIONS ?? ''}`;
|
||||||
|
|
||||||
process.env.GENERATE_SOURCEMAP = 'false';
|
process.env.GENERATE_SOURCEMAP = 'false';
|
||||||
__cleanup.push(...(await patchTauri(env, targets, bundles, args)));
|
__cleanup.push(...(await patchTauri(env, targets, 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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,12 +41,7 @@ export async function tauriUpdateKey(env: CheckedEnvironment): Promise<string |
|
||||||
return keys.publicKey;
|
return keys.publicKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function patchTauri(
|
export async function patchTauri(env: CheckedEnvironment, targets: string[], args: string[]): Promise<string[]> {
|
||||||
env: CheckedEnvironment,
|
|
||||||
targets: string[],
|
|
||||||
bundles: string[],
|
|
||||||
args: string[],
|
|
||||||
): Promise<string[]> {
|
|
||||||
if (args.findIndex(a => ['-c', '--config'].includes(a)) !== -1)
|
if (args.findIndex(a => ['-c', '--config'].includes(a)) !== -1)
|
||||||
throw new Error('custom tauri build configuration is not supported!');
|
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 tauriRoot = join(env.__root, 'apps', 'desktop');
|
||||||
const tauriConfig = JSON.parse(await fs.readFile(join(tauriRoot, 'tauri.conf.json'), 'utf-8'));
|
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]) {
|
switch (args[0]) {
|
||||||
case 'dev':
|
case 'dev':
|
||||||
tauriPatch.build.features.push('devtools');
|
tauriPatch.build.features.push('devtools');
|
||||||
break;
|
break;
|
||||||
case 'build':
|
case 'build':
|
||||||
if (tauriConfig.plugins?.updater?.active) {
|
if (tauriConfig.bundle?.createUpdaterArtifacts !== false) {
|
||||||
const pubKey = await tauriUpdateKey(env);
|
const pubKey = await tauriUpdateKey(env);
|
||||||
if (pubKey != null)
|
if (pubKey != null)
|
||||||
tauriPatch.plugins.updater.pubkey = pubKey;
|
tauriPatch.plugins.updater.pubkey = pubKey;
|
||||||
}
|
}
|
||||||
// tauriPatch.build.features.push('devtools');
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (osType === 'Darwin') {
|
if (osType === 'Darwin') {
|
||||||
const macOSStore = {
|
const macOSStore = {
|
||||||
defaultArm64: '11.0',
|
defaultArm64: '11.0', // arm64 support was added in macOS 11.0
|
||||||
minimumVersion: tauriConfig?.bundle?.macOS?.minimumSystemVersion,
|
minimumVersion: tauriConfig?.bundle?.macOS?.minimumSystemVersion,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue