mirror of
https://github.com/tauri-apps/tauri-action.git
synced 2026-01-31 00:35:20 +01:00
* feat: Handle nsis builds, closes #435 * handle wix+nsis conflict in updater json * rebuild dist * manually convert to bool * fix nsis updater bundle name * change file * reword "Expected artifacts paths", ref #435
This commit is contained in:
5
.changes/nsis-support.md
Normal file
5
.changes/nsis-support.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'action': patch
|
||||
---
|
||||
|
||||
Add support for the NSIS bundle type introduced in Tauri v1.3. Add setting to switch between nsis and msi in the updater json file.
|
||||
19
README.md
19
README.md
@@ -202,15 +202,16 @@ 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 |
|
||||
| `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 | |
|
||||
| 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 |
|
||||
| `updaterJsonPreferNsis` | false | whether the action will use the NSIS (setup.exe) or WiX (.msi) bundles for the updater JSON if both types exist | bool | `false` for Tauri v1 and `true` for Tauri v2+ |
|
||||
| `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,8 @@ inputs:
|
||||
includeUpdaterJson:
|
||||
description: 'whether to upload a static JSON file for the updater using GitHub Releases as the CDN'
|
||||
default: true
|
||||
updaterJsonPreferNsis:
|
||||
description: 'whether the action will use the NSIS (setup.exe) or WiX (.msi) bundles for the updater JSON if both types exist. Will default to false for Tauri v1 and true for Tauri v2+'
|
||||
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
|
||||
|
||||
2
dist/index.js
vendored
2
dist/index.js
vendored
File diff suppressed because one or more lines are too long
@@ -8,7 +8,8 @@
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "ncc build src/index.ts -o dist -m",
|
||||
"lint": "eslint src/**"
|
||||
"lint": "eslint src/**",
|
||||
"format": "prettier -w src/** action.yml README.md"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
21
src/build.ts
21
src/build.ts
@@ -132,6 +132,25 @@ export async function buildProject(
|
||||
);
|
||||
});
|
||||
|
||||
winArtifacts.push(
|
||||
join(
|
||||
artifactsPath,
|
||||
`bundle/nsis/${fileAppName}_${app.version}_${arch}-setup.exe`
|
||||
)
|
||||
);
|
||||
winArtifacts.push(
|
||||
join(
|
||||
artifactsPath,
|
||||
`bundle/nsis/${fileAppName}_${app.version}_${arch}-setup.nsis.zip`
|
||||
)
|
||||
);
|
||||
winArtifacts.push(
|
||||
join(
|
||||
artifactsPath,
|
||||
`bundle/nsis/${fileAppName}_${app.version}_${arch}-setup.nsis.zip.sig`
|
||||
)
|
||||
);
|
||||
|
||||
artifacts = winArtifacts.map((path) => ({ path, arch }));
|
||||
} else {
|
||||
const debianArch =
|
||||
@@ -184,7 +203,7 @@ export async function buildProject(
|
||||
}
|
||||
|
||||
console.log(
|
||||
`Expected artifacts paths:\n${artifacts.map((a) => a.path).join('\n')}`
|
||||
`Looking for artifacts in:\n${artifacts.map((a) => a.path).join('\n')}`
|
||||
);
|
||||
return artifacts.filter((p) => existsSync(p.path));
|
||||
}
|
||||
|
||||
@@ -38,6 +38,13 @@ async function run(): Promise<void> {
|
||||
const prerelease = core.getBooleanInput('prerelease');
|
||||
const commitish = core.getInput('releaseCommitish') || null;
|
||||
|
||||
// TODO: Change its default to true for v2 apps
|
||||
// Not using getBooleanInput so we can differentiate between true,false,unset later.
|
||||
const updaterJsonPreferNsis =
|
||||
core.getInput('updaterJsonPreferNsis')?.toLowerCase() === 'true'
|
||||
? true
|
||||
: false;
|
||||
|
||||
if (!releaseId) {
|
||||
if (Boolean(tagName) !== Boolean(releaseName)) {
|
||||
throw new Error(
|
||||
@@ -155,6 +162,7 @@ async function run(): Promise<void> {
|
||||
releaseId,
|
||||
artifacts,
|
||||
targetInfo,
|
||||
updaterJsonPreferNsis,
|
||||
updaterJsonKeepUniversal,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ export async function uploadVersionJSON({
|
||||
releaseId,
|
||||
artifacts,
|
||||
targetInfo,
|
||||
updaterJsonPreferNsis,
|
||||
updaterJsonKeepUniversal,
|
||||
}: {
|
||||
version: string;
|
||||
@@ -37,6 +38,7 @@ export async function uploadVersionJSON({
|
||||
releaseId: number;
|
||||
artifacts: Artifact[];
|
||||
targetInfo: TargetInfo;
|
||||
updaterJsonPreferNsis: boolean;
|
||||
updaterJsonKeepUniversal: boolean;
|
||||
}) {
|
||||
if (process.env.GITHUB_TOKEN === undefined) {
|
||||
@@ -82,15 +84,31 @@ export async function uploadVersionJSON({
|
||||
).platforms;
|
||||
}
|
||||
|
||||
const sigFile = artifacts.find((s) => s.path.endsWith('.sig'));
|
||||
let sigFile = artifacts.find((s) =>
|
||||
s.path.endsWith(updaterJsonPreferNsis ? '.nsis.zip.sig' : 'msi.zip.sig')
|
||||
);
|
||||
|
||||
if (!sigFile) {
|
||||
sigFile = artifacts.find((s) => s.path.endsWith('.sig'));
|
||||
}
|
||||
|
||||
const assetNames = new Set(
|
||||
artifacts.map((p) => getAssetName(p.path).trim().replace(/ /g, '.')) // GitHub replaces spaces in asset names with dots
|
||||
);
|
||||
let downloadUrl = assets.data
|
||||
.filter((e) => assetNames.has(e.name))
|
||||
.find(
|
||||
(s) => s.name.endsWith('.tar.gz') || s.name.endsWith('.zip')
|
||||
)?.browser_download_url;
|
||||
let downloadUrl;
|
||||
{
|
||||
const filteredAssets = assets.data.filter((e) => assetNames.has(e.name));
|
||||
const filtAsset = filteredAssets.find((s) =>
|
||||
s.name.endsWith(updaterJsonPreferNsis ? '.nsis.zip' : '.msi.zip')
|
||||
);
|
||||
if (filtAsset) {
|
||||
downloadUrl = filtAsset.browser_download_url;
|
||||
} else {
|
||||
downloadUrl = filteredAssets.find(
|
||||
(s) => s.name.endsWith('.tar.gz') || s.name.endsWith('.zip')
|
||||
)?.browser_download_url;
|
||||
}
|
||||
}
|
||||
|
||||
// Untagged release downloads won't work after the release was published
|
||||
downloadUrl = downloadUrl?.replace(
|
||||
|
||||
@@ -22,6 +22,9 @@ export const extensions = [
|
||||
'.msi.zip.sig',
|
||||
'.msi.zip',
|
||||
'.msi',
|
||||
'.nsis.zip.sig',
|
||||
'.nsis.zip',
|
||||
'.exe',
|
||||
];
|
||||
|
||||
/*** helper functions ***/
|
||||
|
||||
Reference in New Issue
Block a user