refactor!: split workflow artifact configs (#1183)

This commit is contained in:
Fabian-Lars
2025-11-15 13:22:54 +01:00
committed by GitHub
parent c4979999df
commit c18827ebec
8 changed files with 47 additions and 43 deletions

View File

@@ -0,0 +1,5 @@
---
action: major
---
**Breaking Change**: Renamed `assetNamePattern` to `releaseAssetNamePattern`.

View File

@@ -82,5 +82,5 @@ jobs:
retryAttempts: 1
uploadPlainBinary: true
uploadWorkflowArtifacts: true
# uploadWorkflowArtifacts: '[name]_${{ github.sha }}_[platform]_[arch]_[bundle]'
# assetNamePattern: '[name]x[version]x[platform]x[arch]x[mode]x[setup]x[ext]'
# workflowArtifactNamePattern: '[name]_${{ github.sha }}_[platform]_[arch]_[bundle]'
# releaseAssetNamePattern: '[name]x[version]x[platform]x[arch]x[mode]x[setup]x[ext]'

View File

@@ -95,24 +95,25 @@ These inputs allow you to change how your Tauri project will be build.
These inputs allow you to modify the GitHub release.
| Name | Required | Description | Type | Default |
| ------------------------- | :------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------- | ------------------------------------------- |
| `releaseId` | false | The id of the release to upload artifacts as release assets. If set, `tagName` and `releaseName` will not be considered to find a release. | number | |
| `tagName` | false | The tag name of the release to upload/create or the tag of the release belonging to `releaseId` | string | |
| `releaseName` | false | The name of the release to create. Required if there's no existing release for `tagName` | string | |
| `releaseBody` | false | The body of the release to create | string | |
| `releaseDraft` | false | Whether the release to find or create is a draft or not | bool | false |
| `prerelease` | false | Whether the release to create is a prerelease or not | bool | false |
| `releaseCommitish` | false | Any branch or commit SHA the Git tag is created from, unused if the Git tag already exists. | string | SHA of current commit |
| `generateReleaseNotes` | false | Whether to use GitHub's Release Notes API to generate the release title and body. If `releaseName` is set, it will overwrite the generated title. If `releaseBody` is set, it will be pre-pended to the automatically generated notes. This action is not responsible for the generated content. | bool | false |
| `owner` | false | The account owner of the repository the release will be uploaded to. Requires `GITHUB_TOKEN` in env and a `releaseCommitish` target if it doesn't match the current repo. | string | owner of the current repo |
| `repo` | false | The name of the repository the release will be uploaded to. Requires `GITHUB_TOKEN` in env and a `releaseCommitish` target if it doesn't match the current repo. | string | name of the current repo |
| `githubBaseUrl` | false | The base URL of the GitHub API to use. This is useful if you want to use a self-hosted GitHub instance or a GitHub Enterprise server. | string | `$GITHUB_API_URL` or https://api.github.com |
| `isGitea` | false | Whether to run in Gitea compatibility mode. Set this if `githubBaseUrl` targets a Gitea instance, since some API endpoints differ from GitHub. | bool | false |
| `assetNamePattern` | false | The naming pattern to use for the uploaded assets. If not set, the names given by Tauri's CLI are kept. | string | none |
| `uploadPlainBinary` | false | Whether to upload the unbundled executable binary or not. Requires Tauri v2+. To prevent issues with Tauri's [`bundle_type`](https://docs.rs/tauri-utils/latest/tauri_utils/platform/fn.bundle_type.html) value this should only be used with the `--no-bundle` flag. | bool | false |
| `uploadWorkflowArtifacts` | false | Whether to upload the bundles and executables as [workflow artifacts](https://docs.github.com/en/actions/concepts/workflows-and-actions/workflow-artifacts). Independent from the release configs. Affected by `uploadPlainBinary`. Can be a string to set a name pattern with the same syntax as `assetNamePattern`, defaults to `platform-arch-bundletype` if set to `true`. | bool / string | false |
| `uploadUpdaterSignatures` | false | Whether to upload the .sig files generated by Tauri. Does not affect the `latest.json` generator. | bool | true |
| Name | Required | Description | Type | Default |
| ------------------------------ | :------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------ | ------------------------------------------- |
| `releaseId` | false | The id of the release to upload artifacts as release assets. If set, `tagName` and `releaseName` will not be considered to find a release. | number | |
| `tagName` | false | The tag name of the release to upload/create or the tag of the release belonging to `releaseId` | string | |
| `releaseName` | false | The name of the release to create. Required if there's no existing release for `tagName` | string | |
| `releaseBody` | false | The body of the release to create | string | |
| `releaseDraft` | false | Whether the release to find or create is a draft or not | bool | false |
| `prerelease` | false | Whether the release to create is a prerelease or not | bool | false |
| `releaseCommitish` | false | Any branch or commit SHA the Git tag is created from, unused if the Git tag already exists. | string | SHA of current commit |
| `generateReleaseNotes` | false | Whether to use GitHub's Release Notes API to generate the release title and body. If `releaseName` is set, it will overwrite the generated title. If `releaseBody` is set, it will be pre-pended to the automatically generated notes. This action is not responsible for the generated content. | bool | false |
| `owner` | false | The account owner of the repository the release will be uploaded to. Requires `GITHUB_TOKEN` in env and a `releaseCommitish` target if it doesn't match the current repo. | string | owner of the current repo |
| `repo` | false | The name of the repository the release will be uploaded to. Requires `GITHUB_TOKEN` in env and a `releaseCommitish` target if it doesn't match the current repo. | string | name of the current repo |
| `githubBaseUrl` | false | The base URL of the GitHub API to use. This is useful if you want to use a self-hosted GitHub instance or a GitHub Enterprise server. | string | `$GITHUB_API_URL` or https://api.github.com |
| `isGitea` | false | Whether to run in Gitea compatibility mode. Set this if `githubBaseUrl` targets a Gitea instance, since some API endpoints differ from GitHub. | bool | false |
| `releaseAssetNamePattern` | false | The naming pattern to use for the uploaded assets. If not set, the names given by Tauri's CLI are kept. | string | none |
| `uploadPlainBinary` | false | Whether to upload the unbundled executable binary or not. Requires Tauri v2+. To prevent issues with Tauri's [`bundle_type`](https://docs.rs/tauri-utils/latest/tauri_utils/platform/fn.bundle_type.html) value this should only be used with the `--no-bundle` flag. | bool | false |
| `uploadWorkflowArtifacts` | false | Whether to upload the bundles and executables as [workflow artifacts](https://docs.github.com/en/actions/concepts/workflows-and-actions/workflow-artifacts). Independent from the release configs. Affected by `uploadPlainBinary`. | bool | false |
| `workflowArtifactsNamePattern` | false | The naming pattern to use for uploaded [workflow artifacts](https://docs.github.com/en/actions/concepts/workflows-and-actions/workflow-artifacts). Ignored if `uploadWorkflowArtifacts` is not enabled. | string | `[platform]-[arch]-[bundle]` |
| `uploadUpdaterSignatures` | false | Whether to upload the .sig files generated by Tauri. Does not affect the `latest.json` generator. | bool | true |
## Outputs
@@ -138,11 +139,11 @@ These inputs allow you to modify the GitHub release.
- If you provide a `tagName` to an existing release, `releaseDraft` must be set to `true` if the existing release is a draft.
- If you only want to build the app without having the action upload any assets, for example if you want to only use [`actions/upload-artifact`](https://github.com/actions/upload-artifact), simply omit `tagName`, `releaseName` and `releaseId`.
- Only enable `uploadPlainBinary` if you are sure what you're doing since Tauri doesn't officially support a portable mode, especially on platforms other than Windows where standalone binaries for GUI applications basically do not exist.
- `assetNamePattern` offers a few variables that will be replaced automatically if encapsulated in `[]`. Currently available variables are: `[name]`, `[version]`, `[platform]`, `[arch]`, `[mode]`, `[setup]`, `[_setup]`, `[ext]`, `[bundle]`.
- `releaseAssetNamePattern` offers a few variables that will be replaced automatically if encapsulated in `[]`. Currently available variables are: `[name]`, `[version]`, `[platform]`, `[arch]`, `[mode]`, `[setup]`, `[_setup]`, `[ext]`, `[bundle]`.
- `[mode]` will be replaced with `debug` or `release`, depending on the use of the `--debug` flag in `args`.
- `[setup]` will be replaced with `-setup` which can be used to differenciate between the NSIS installer and the binary from `uploadPlainBinary`. For all other bundle types it will be an empty string.
- `[_setup]` behaves like `[setup]` but with `_setup` instead of `-setup`.
- `[bundle]` will be replaced with one of `app`, `dmg`, `msi`, `nsis`, `appimage`, `deb`, `rpm`, `bin` (for `uploadPlainBinary`). This is likely only useful for `uploadWorkflowArtifacts` and _not_ for `assetNamePattern` because of its conflict with `[ext]`.
- `[bundle]` will be replaced with one of `app`, `dmg`, `msi`, `nsis`, `appimage`, `deb`, `rpm`, `bin` (for `uploadPlainBinary`). This is likely only useful for `workflowArtifactNamePattern` and _not_ for `releaseAssetNamePattern` because of its conflict with `[ext]`.
- Gitea support is experimental. It was implemented and tested solely by the community.
- `uploadWorkflowArtifacts` will likely be removed once [actions/upload-artifact#331](https://github.com/actions/upload-artifact/issues/331) lands.

View File

@@ -47,14 +47,16 @@ inputs:
isGitea:
description: 'Whether to run in Gitea compatibility mode. Set this if `githubBaseUrl` targets a Gitea instance, since some API endpoints differ from GitHub'
default: 'false'
assetNamePattern:
releaseAssetNamePattern:
description: 'The naming pattern to use for the uploaded assets'
uploadPlainBinary:
description: 'Whether to upload the plain executable file to the GitHub Releases'
default: 'false'
uploadWorkflowArtifacts:
description: 'Whether to upload the bundles and executables as workflow artifacts. Independent from the release configs. Can be a string to set a name pattern.'
description: 'Whether to upload the bundles and executables as workflow artifacts. Independent from the release configs. Affected by `uploadPlainBinary`.'
default: 'false'
workflowArtifactsNamePattern:
description: 'The naming pattern to use for uploaded workflow artifacts. Ignored if `uploadWorkflowArtifacts` is not enabled.'
uploadUpdaterSignatures:
description: 'Whether to upload the .sig files generated by the Tauri CLI. Does not affect the latest.json generator.'
default: 'true'

2
dist/index.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -27,7 +27,7 @@ async function run(): Promise<void> {
const retryAttempts = parseInt(core.getInput('retryAttempts') || '0', 10);
const tauriScript = core.getInput('tauriScript');
const args = stringArgv(core.getInput('args'));
const assetNamePattern = core.getInput('assetNamePattern');
const releaseAssetNamePattern = core.getInput('releaseAssetNamePattern');
const uploadPlainBinary = core.getBooleanInput('uploadPlainBinary');
let tagName = core.getInput('tagName').replace('refs/tags/', '');
@@ -45,16 +45,12 @@ async function run(): Promise<void> {
'https://api.github.com';
const isGitea = core.getBooleanInput('isGitea');
const generateReleaseNotes = core.getBooleanInput('generateReleaseNotes');
let shouldUploadWorkflowArtifacts: boolean | string = false;
try {
shouldUploadWorkflowArtifacts = core.getBooleanInput(
'uploadWorkflowArtifacts',
);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (e) {
shouldUploadWorkflowArtifacts =
core.getInput('uploadWorkflowArtifacts') || false;
}
const shouldUploadWorkflowArtifacts = core.getBooleanInput(
'uploadWorkflowArtifacts',
);
const workflowArtifactsNamePattern =
core.getInput('workflowArtifactsNamePattern') ||
'[platform]-[arch]-[bundle]';
const uplodaUpdaterSignatures = core.getBooleanInput(
'uploadUpdaterSignatures',
);
@@ -117,7 +113,7 @@ async function run(): Promise<void> {
if (shouldUploadWorkflowArtifacts) {
await uploadWorkflowArtifacts(
artifacts,
shouldUploadWorkflowArtifacts,
workflowArtifactsNamePattern,
retryAttempts,
);
}
@@ -198,7 +194,7 @@ async function run(): Promise<void> {
retryAttempts,
githubBaseUrl,
isGitea,
assetNamePattern,
releaseAssetNamePattern,
uplodaUpdaterSignatures,
);
@@ -218,7 +214,7 @@ async function run(): Promise<void> {
retryAttempts,
githubBaseUrl,
isGitea,
assetNamePattern,
releaseAssetNamePattern,
);
}
} else {

View File

@@ -13,7 +13,7 @@ export async function uploadAssets(
retryAttempts: number,
githubBaseUrl: string,
isGitea: boolean,
assetNamePattern?: string,
releaseAssetNamePattern?: string,
uploadUpdaterSignatures?: boolean,
) {
if (process.env.GITHUB_TOKEN === undefined) {
@@ -46,7 +46,7 @@ export async function uploadAssets(
'content-length': contentLength(asset.path),
};
const assetName = getAssetName(asset, assetNamePattern);
const assetName = getAssetName(asset, releaseAssetNamePattern);
const existingAsset = existingAssets.find(
(a) =>

View File

@@ -38,7 +38,7 @@ export async function uploadVersionJSON(
retryAttempts: number,
githubBaseUrl: string,
isGitea: boolean,
assetNamePattern?: string,
releaseAssetNamePattern?: string,
) {
if (process.env.GITHUB_TOKEN === undefined) {
throw new Error('GITHUB_TOKEN is required');
@@ -119,7 +119,7 @@ export async function uploadVersionJSON(
// Assets matching artifacts generated by this action
const filteredAssets = [];
for (const artifact of artifacts) {
const assetName = getAssetName(artifact, assetNamePattern)
const assetName = getAssetName(artifact, releaseAssetNamePattern)
.trim()
.replace(/[ ()[\]{}]/g, '.')
.replace(/\.\./g, '.')