Skip to content

Commit

Permalink
feat(core): add bundle identifier option (#263)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog committed May 11, 2022
1 parent 0bff873 commit 743a37f
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .changes/bundle-identifier.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@tauri-apps/action-core": patch
"action": patch
---

Added the `bundleIdentifier` input to modify Tauri's default bundle identifier when initializing a new Tauri app.
1 change: 1 addition & 0 deletions .github/workflows/test-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ jobs:
TAURI_PRIVATE_KEY: dW50cnVzdGVkIGNvbW1lbnQ6IHJzaWduIGVuY3J5cHRlZCBzZWNyZXQga2V5ClJXUlRZMEl5YTBGV3JiTy9lRDZVd3NkL0RoQ1htZmExNDd3RmJaNmRMT1ZGVjczWTBKZ0FBQkFBQUFBQUFBQUFBQUlBQUFBQWdMekUzVkE4K0tWQ1hjeGt1Vkx2QnRUR3pzQjVuV0ZpM2czWXNkRm9hVUxrVnB6TUN3K1NheHJMREhQbUVWVFZRK3NIL1VsMDBHNW5ET1EzQno0UStSb21nRW4vZlpTaXIwZFh5ZmRlL1lSN0dKcHdyOUVPclVvdzFhVkxDVnZrbHM2T1o4Tk1NWEU9Cg==
with:
projectPath: ./packages/action/__fixtures__/example
bundleIdentifier: com.tauri.actiontest
# iconPath: ./icon.png
tagName: example-v__VERSION__
releaseName: "Release example app v__VERSION__"
Expand Down
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ inputs:
description: 'the script to run to build the Tauri app'
args:
description: 'arguments for the tauri command'
bundleIdentifier:
description: 'the bundle identifier to inject when initializing the Tauri app'
outputs:
releaseId:
description: 'The ID of the created release'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"bundle": {
"active": true,
"targets": "all",
"identifier": "com.tauri.dev",
"identifier": "com.tauri.actiontest",
"icon": [
"icons/32x32.png",
"icons/128x128.png",
Expand Down
4 changes: 2 additions & 2 deletions packages/action/dist/index.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion packages/action/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ async function run(): Promise<void> {
const includeDebug = core.getBooleanInput('includeDebug')
const tauriScript = core.getInput('tauriScript')
const args = stringArgv(core.getInput('args'))
const bundleIdentifier = core.getInput('bundleIdentifier')

let tagName = core.getInput('tagName').replace('refs/tags/', '')
let releaseName = core.getInput('releaseName').replace('refs/tags/', '')
Expand All @@ -42,7 +43,8 @@ async function run(): Promise<void> {
distPath,
iconPath,
tauriScript,
args
args,
bundleIdentifier
}
const info = getInfo(projectPath)
const artifacts = await buildProject(projectPath, false, options)
Expand Down
18 changes: 17 additions & 1 deletion packages/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ interface TauriConfig {
}
tauri?: {
bundle?: {
identifier: string
windows?: {
wix?: {
language?: string | string[] | { [language: string]: unknown }
Expand All @@ -145,6 +146,7 @@ export interface BuildOptions {
iconPath: string | null
tauriScript: string | null
args: string[] | null
bundleIdentifier: string | null
}

export interface Runner {
Expand Down Expand Up @@ -240,7 +242,7 @@ export function getInfo(root: string): Info {
export async function buildProject(
root: string,
debug: boolean,
{ configPath, distPath, iconPath, tauriScript, args }: BuildOptions
{ configPath, distPath, iconPath, tauriScript, args, bundleIdentifier }: BuildOptions
): Promise<string[]> {
return new Promise<Runner>((resolve, reject) => {
if (tauriScript) {
Expand Down Expand Up @@ -306,6 +308,20 @@ export async function buildProject(
pkgConfig.productName = packageJson.productName
}
config.package = pkgConfig

if (bundleIdentifier) {
console.log(
`Replacing tauri.conf.json config - tauri.bundle.identifier=${bundleIdentifier}`
)
config.tauri = {
...config.tauri,
bundle: {
...config.tauri?.bundle,
identifier: bundleIdentifier
}
}
}

writeFileSync(configPath, JSON.stringify(config, null, 2))

const app = {
Expand Down

0 comments on commit 743a37f

Please sign in to comment.