mirror of
https://github.com/tauri-apps/tauri-action.git
synced 2026-01-31 00:35:20 +01:00
* remove unused imports * feat: Handle universal macos in updater json * readme
This commit is contained in:
5
.changes/macos-universal-target.md
Normal file
5
.changes/macos-universal-target.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'action': patch
|
||||
---
|
||||
|
||||
Correctly handle universal macOS builds in the updater JSON file. Unless disabled it will add the universal builds to the darwin-aarch64 and darwin-x86_64 fields instead of darwin-universal. It will always prefer native targets for the respective fields if they exist.
|
||||
17
README.md
17
README.md
@@ -202,14 +202,15 @@ These inputs are _typically_ only used if your GitHub repo does not contain an e
|
||||
|
||||
These inputs allow you to change how your Tauri project will be build.
|
||||
|
||||
| Name | Required | Description | Type | Default |
|
||||
| -------------------- | :------: | ------------------------------------------------------------------------------------------------- | ------ | --------------------------- |
|
||||
| `projectPath` | false | The path to the root of the tauri project relative to the current working directory | string | . |
|
||||
| `includeDebug` | false | whether to include a debug build or not | bool | false |
|
||||
| `includeRelease` | false | whether to include a release build or not | bool | true |
|
||||
| `includeUpdaterJson` | false | whether to upload a JSON file for the updater or not (only relevant if the updater is configured) | bool | true |
|
||||
| `tauriScript` | false | the script to execute the Tauri CLI. It must not include any args or commands like `build` | string | `npm run\|pnpm\|yarn tauri` |
|
||||
| `args` | false | Additional arguments to the current build command | string | |
|
||||
| Name | Required | Description | Type | Default |
|
||||
| -------------------------- | :------: | ---------------------------------------------------------------------------------------------------------------------------- | ------ | --------------------------- |
|
||||
| `projectPath` | false | The path to the root of the tauri project relative to the current working directory | string | . |
|
||||
| `includeDebug` | false | whether to include a debug build or not | bool | false |
|
||||
| `includeRelease` | false | whether to include a release build or not | bool | true |
|
||||
| `includeUpdaterJson` | false | whether to upload a JSON file for the updater or not (only relevant if the updater is configured) | bool | true |
|
||||
| `updaterJsonKeepUniversal` | false | whether the updater JSON file should include universal macOS builds as darwin-universal or in the aarch64 and x86_64 fields. | bool | false |
|
||||
| `tauriScript` | false | the script to execute the Tauri CLI. It must not include any args or commands like `build` | string | `npm run\|pnpm\|yarn tauri` |
|
||||
| `args` | false | Additional arguments to the current build command | string | |
|
||||
|
||||
### Release Configuration
|
||||
|
||||
|
||||
@@ -36,6 +36,9 @@ inputs:
|
||||
includeUpdaterJson:
|
||||
description: 'whether to upload a static JSON file for the updater using GitHub Releases as the CDN'
|
||||
default: true
|
||||
updaterJsonKeepUniversal:
|
||||
description: 'whether the updater JSON file should add universal macOS as darwin-universal. By default it will add darwin-aarch64 and darwin-x86_64 fields pointing to the universal build if no native builds exist.'
|
||||
default: false
|
||||
tauriScript:
|
||||
description: 'the script to run to build the Tauri app'
|
||||
args:
|
||||
|
||||
2
dist/index.js
vendored
2
dist/index.js
vendored
File diff suppressed because one or more lines are too long
@@ -1,4 +1,4 @@
|
||||
import { readFileSync, existsSync, copyFileSync, writeFileSync } from 'fs';
|
||||
import { existsSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
|
||||
import { initProject } from './init-project';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { existsSync } from 'fs';
|
||||
import { platform } from 'os';
|
||||
import { join, resolve, dirname, basename } from 'path';
|
||||
import { resolve, dirname, basename } from 'path';
|
||||
|
||||
import * as core from '@actions/core';
|
||||
import stringArgv from 'string-argv';
|
||||
@@ -24,6 +23,9 @@ async function run(): Promise<void> {
|
||||
const includeRelease = core.getBooleanInput('includeRelease');
|
||||
const includeDebug = core.getBooleanInput('includeDebug');
|
||||
const includeUpdaterJson = core.getBooleanInput('includeUpdaterJson');
|
||||
const updaterJsonKeepUniversal = core.getBooleanInput(
|
||||
'updaterJsonKeepUniversal'
|
||||
);
|
||||
const tauriScript = core.getInput('tauriScript');
|
||||
const args = stringArgv(core.getInput('args'));
|
||||
const bundleIdentifier = core.getInput('bundleIdentifier');
|
||||
@@ -153,6 +155,7 @@ async function run(): Promise<void> {
|
||||
releaseId,
|
||||
artifacts,
|
||||
targetInfo,
|
||||
updaterJsonKeepUniversal,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { readFileSync, writeFileSync } from 'fs';
|
||||
import { platform } from 'os';
|
||||
import { resolve } from 'path';
|
||||
|
||||
import { getOctokit, context } from '@actions/github';
|
||||
@@ -30,6 +29,7 @@ export async function uploadVersionJSON({
|
||||
releaseId,
|
||||
artifacts,
|
||||
targetInfo,
|
||||
updaterJsonKeepUniversal,
|
||||
}: {
|
||||
version: string;
|
||||
notes: string;
|
||||
@@ -37,6 +37,7 @@ export async function uploadVersionJSON({
|
||||
releaseId: number;
|
||||
artifacts: Artifact[];
|
||||
targetInfo: TargetInfo;
|
||||
updaterJsonKeepUniversal: boolean;
|
||||
}) {
|
||||
if (process.env.GITHUB_TOKEN === undefined) {
|
||||
throw new Error('GITHUB_TOKEN is required');
|
||||
@@ -115,11 +116,27 @@ export async function uploadVersionJSON({
|
||||
? 'aarch64'
|
||||
: arch;
|
||||
|
||||
// https://github.com/tauri-apps/tauri/blob/fd125f76d768099dc3d4b2d4114349ffc31ffac9/core/tauri/src/updater/core.rs#L856
|
||||
(versionContent.platforms[`${os}-${arch}`] as unknown) = {
|
||||
signature: readFileSync(sigFile.path).toString(),
|
||||
url: downloadUrl,
|
||||
};
|
||||
// Expected targets: https://github.com/tauri-apps/tauri/blob/fd125f76d768099dc3d4b2d4114349ffc31ffac9/core/tauri/src/updater/core.rs#L856
|
||||
if (!updaterJsonKeepUniversal && os === 'darwin' && arch === 'universal') {
|
||||
// Don't overwrite native builds
|
||||
if (!versionContent.platforms['darwin-aarch64']) {
|
||||
(versionContent.platforms['darwin-aarch64'] as unknown) = {
|
||||
signature: readFileSync(sigFile.path).toString(),
|
||||
url: downloadUrl,
|
||||
};
|
||||
}
|
||||
if (!versionContent.platforms['darwin-x86_64']) {
|
||||
(versionContent.platforms['darwin-x86_64'] as unknown) = {
|
||||
signature: readFileSync(sigFile.path).toString(),
|
||||
url: downloadUrl,
|
||||
};
|
||||
}
|
||||
} else {
|
||||
(versionContent.platforms[`${os}-${arch}`] as unknown) = {
|
||||
signature: readFileSync(sigFile.path).toString(),
|
||||
url: downloadUrl,
|
||||
};
|
||||
}
|
||||
|
||||
writeFileSync(versionFile, JSON.stringify(versionContent, null, 2));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user