codemagic-ci-cd / cli-tools

Various utilities to managing Android and iOS app builds, code signing, and deployment.
https://codemagic.io/start/
GNU General Public License v3.0
243 stars 42 forks source link

Output version number together with build number when running `app-store-connect get-latest-testflight-build-number --json` #344

Closed aparajita closed 11 months ago

aparajita commented 12 months ago

These are awesome tools, thank you so much!

The --json argument is not working for me. For example:

app-store-connect get-latest-testflight-build-number --json --not-expired --issuer-id my-issuer-id --key-id my-key-id --private-key @file:/path/to/authkey.p8 12345678

Returns:

Found build number 84 from TestFlight version 4.1.0
84

Am I doing something wrong, or is this a known bug?

priitlatt commented 12 months ago

Hi @aparajita. As integers are valid JSON data types, then this is actually intended behaviour. Consider the following example:

$ VERSION=$(app-store-connect get-latest-testflight-build-number 1550275619 | jq)
Found build number 10 from TestFlight version 1.0.2
$ echo $VERSION
10

Note informative log lines are written to STDERR stream (by default) and are not captured by piping or variable initialization unless stream redirection is used.

All in all, in case of integer versions there is no difference in JSON and regular output.

priitlatt commented 12 months ago

Actually, on a second thought, there seems to be a bug indeed. As version attribute of PreReleaseVersion and versionString attribute of AppStoreVersion are both strings, then using --json flag should wrap the version in quotes. And in case the build number is not a number, which is completely valid case, then this cannot be piped to JSON parser, say jq, at all as of now:

$ app-store-connect get-latest-testflight-build-number 1481211155 | jq
Found build number 2.0.335.528 from TestFlight version 2.0.335
parse error: Invalid numeric literal at line 2, column 0
aparajita commented 12 months ago
Found build number 10 from TestFlight version 1.0.2

Since the tool obviously figures out the version, I was hoping (and kind of expecting) the json output would be like this:

{
  "version": "1.0.2",
  "build": "10"
}

Unless I'm missing something, otherwise to get the corresponding app version we have to explicitly go through the several steps you go through internally to get it.

Would it be possible to add an --include-version option (or something like that) to return the JSON outlined above?

priitlatt commented 11 months ago

Since altering the default behaviour of what --json does would be breaking for existing users, we cannot always include the version info in the output. However, I don't see a reason why this specific action and other similar ones (get-latest-build-number and get-latest-app-store-build-number) couldn't output both version and build number as proposed when additional flag is passed.

aparajita commented 11 months ago

Since altering the default behaviour of what --json does would be breaking for existing users

That's why I proposed a new flag. 😁

priitlatt commented 11 months ago

@aparajita This feature is now released and is available in version 0.45.0. More details can be seen from the description of PR #349. Example usages can be seen from this screenshot:

Screenshot 2023-09-15 at 13 41 47