tauri-apps / tauri-action

Build your Web application as a Tauri binary for macOS, Linux and Windows
https://tauri.app
MIT License
782 stars 134 forks source link

Unable to change app version when building #817

Closed haleksandre closed 4 weeks ago

haleksandre commented 4 weeks ago

I'm currently testing pre-releases & encountered the Wix numerical-only error.

First I tried the appVersion input, but it seems to only be used on tauri init here:

https://github.com/tauri-apps/tauri-action/blob/30a40ff2cb94468d761671ffa0fc20f1056bb3ec/src/build.ts#L46-L50

Next I tried to change the args to include --config flag on pre-release. Something along the line of this

      matrix:
        include:
         # ..other matrice
          - platform: windows-latest
            target: x86_64-pc-windows-msvc
            args: | 
              --target x86_64-pc-windows-msvc ${{ needs.release.outputs.prerelease && format('--config ''{{ \"version\": \"{0}\" }}''', needs.release.outputs.number) || '' }}
Run tauri-apps/tauri-action@v0
  with:
    tauriScript: bun x tauri
    args: --target x86_64-pc-windows-msvc --config '{ \"version\": \"1.0.0-3000\" }'
    releaseId: 159101875
    releaseDraft: false
    prerelease: false
    projectPath: .
    includeDebug: false
    includeRelease: true
    includeUpdaterJson: true
    updaterJsonKeepUniversal: false
  env:
    CARGO_HOME: C:\Users\runneradmin/.cargo
    CARGO_INCREMENTAL: 0
    CARGO_TERM_COLOR: always
    TAURI_SIGNING_PRIVATE_KEY: ***
    TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ***
    GITHUB_TOKEN: ***
Couldn't parse --config flag as inline JSON. This is not an error if it's a file path. Source: "Expected property name or '}' in JSON at position [2](https://github.com/haleksandre/tauri-sveltekit/actions/runs/9393882455/job/25870671290#step:4:2)"
Error: Provided config path `D:\a\tauri-sveltekit\tauri-sveltekit\{ \` does not exist.

If I do not escape the " (double quote).

      matrix:
        include:
         # ..other matrice
          - platform: windows-latest
            target: x86_64-pc-windows-msvc
            args: | 
              --target x86_64-pc-windows-msvc ${{ needs.release.outputs.prerelease && format('--config ''{{ "version": "{0}" }}''', needs.release.outputs.number) || '' }}
Run tauri-apps/tauri-action@v0
  with:
    tauriScript: bun x tauri
    args: --target x86_64-pc-windows-msvc --config '{ "version": "1.0.0-3000" }'

    releaseId: 159[2](https://github.com/haleksandre/tauri-sveltekit/actions/runs/9402417339/job/25896519156#step:4:2)03491
    releaseDraft: false
    prerelease: false
    projectPath: .
    includeDebug: false
    includeRelease: true
    includeUpdaterJson: true
    updaterJsonKeepUniversal: false
  env:
    CARGO_HOME: C:\Users\runneradmin/.cargo
    CARGO_INCREMENTAL: 0
    CARGO_TERM_COLOR: always
    TAURI_SIGNING_PRIVATE_KEY: ***
    TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ***
    GITHUB_TOKEN: ***
running bun [
  'x',
  'tauri',
  'build',
  '--target',
  'x86_64-pc-windows-msvc',
  '--config',
  '{ "version": "1.0.0-3000" }'
]
error: invalid value '{' for '--config <CONFIG>': invalid configuration JSON
For more information, try '--help'.
Error: Command failed with exit code 2: bun x tauri build --target x86_6[4](https://github.com/haleksandre/tauri-sveltekit/actions/runs/9402417339/job/25896519156#step:4:4)-pc-windows-msvc --config "{ ""version"": ""1.0.0-3000"" }"```

But somehow, even though it's valid JSON & works locally, it fails in the action regardless of how the JSON is passed. Is it a bug on how the --config flag gets processes here ?

https://github.com/tauri-apps/tauri-action/blob/30a40ff2cb94468d761671ffa0fc20f1056bb3ec/src/build.ts#L34-L38

haleksandre commented 4 weeks ago

After thinking about it, I figureda way to make the parsed string remain a string to be then passed on to the tauri build command.

If anyone has issues passing JSON to the --config flag in the Github Actions, I was able to make the string parse correctly by first escaping a ' (single quote) & then adding a " (double quote) & finally escaping the " (double quote) within the JSON, like so:

      matrix:
        include:
         # ..other matrice
          - platform: windows-latest
            target: x86_64-pc-windows-msvc
            args: | 
              --target x86_64-pc-windows-msvc ${{ needs.release.outputs.prerelease && format('--config ''"{{ \"version\": \"{0}\" }}"''', needs.release.outputs.number) || '' }}

This made it so the single quoted string to be parsed & remained a string as double quoted string to then be passed to the --config argument.

Run tauri-apps/tauri-action@v0
  with:
    tauriScript: bun x tauri
    args: --target x86_64-pc-windows-msvc --config '"{ \"version\": \"1.0.0-3000\" }"'

    releaseId: 159[2](https://github.com/haleksandre/tauri-sveltekit/actions/runs/9402697312/job/25897435344#step:4:2)06869
    releaseDraft: false
    prerelease: false
    projectPath: .
    includeDebug: false
    includeRelease: true
    includeUpdaterJson: true
    updaterJsonKeepUniversal: false
  env:
    CARGO_HOME: C:\Users\runneradmin/.cargo
    CARGO_INCREMENTAL: 0
    CARGO_TERM_COLOR: always
    TAURI_SIGNING_PRIVATE_KEY: ***
    TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ***
    GITHUB_TOKEN: ***
running bun [
  'x',
  'tauri',
  'build',
  '--target',
  'x86_64-pc-windows-msvc',
  '--config',
  '"{ \\"version\\": \\"1.0.0-3000\\" }"'
]
# ... building starting