Skip to content

Commit

Permalink
fix: Detect v1 bundles with ()[]{} removed from productName. (#837)
Browse files Browse the repository at this point in the history
* fix: Detect v1 bundles with `()[]{}` removed from productName.

* add parans to tests

* regex 101

* accomodate github's asset renaming

* log

* .. -> .

* rm log
  • Loading branch information
FabianLars authored Jun 26, 2024
1 parent 97cc3d1 commit f8044a1
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changes/fix-parans-in-prodname.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
action: patch
---

Fixed an issue that caused the action to be unable to pick up the app bundles if the `productName` contained any of these characters: `()[]{}`.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"beforeBuildCommand": ""
},
"package": {
"productName": "TauriExample App",
"productName": "TauriExample App (v1)",
"version": "0.1.1"
},
"tauri": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"productName": "TauriExample App",
"productName": "TauriExample App (v2)",
"version": "0.1.2",
"identifier": "com.tauri.actiontest",
"build": {
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,13 @@ export async function buildProject(

await runner.execTauriCommand(['build'], [...tauriArgs], root);

// on Linux, the app product name is converted to kebab-case
// on Linux, the app product name is converted to kebab-case and `()[]{}` will be removed
// with tauri-cli 2.0.0-beta.19 deb and appimage will now use the product name as on the other platforms.
const linuxFileAppName = app.name
.replace(/([a-z0-9])([A-Z])/g, '$1-$2')
.replace(/([A-Z])([A-Z])(?=[a-z])/g, '$1-$2')
.replace(/[ _.]/g, '-')
.replace(/[()[\]{}]/g, '')
.toLowerCase();

const workspacePath = getWorkspaceDir(app.tauriPath) ?? app.tauriPath;
Expand Down
7 changes: 6 additions & 1 deletion src/upload-release-assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ export async function uploadAssets(
const assetName = getAssetName(asset.path);

const existingAsset = existingAssets.find(
(a) => a.name === assetName.trim().replace(/ /g, '.'),
(a) =>
a.name ===
assetName
.trim()
.replace(/[ ()[\]{}]/g, '.')
.replace(/\.\./g, '.'),
);
if (existingAsset) {
console.log(`Deleting existing ${assetName}...`);
Expand Down
6 changes: 5 additions & 1 deletion src/upload-version-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ export async function uploadVersionJSON({
}

const assetNames = new Set(
artifacts.map((p) => getAssetName(p.path).trim().replace(/ /g, '.')), // GitHub replaces spaces in asset names with dots
artifacts.map((p) =>
getAssetName(p.path)
.trim()
.replace(/[ ()[\]{}]/g, '.'),
), // GitHub replaces spaces and special chars in asset names with dots
);
let downloadUrl;
{
Expand Down

0 comments on commit f8044a1

Please sign in to comment.