diff options
author | Kevin Song <chips@ksong.dev> | 2023-10-01 01:59:34 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-01 08:59:34 +0200 |
commit | 001253cebe8655a27fdf344fe3f36a72f12fe539 (patch) | |
tree | 643839959a20b681deba6395b170d7c86a2f1d24 | |
parent | 8168c21293de8118af1e95778b1eee8f26cd6d6a (diff) |
ci: Fix how version is obtained for pkgbuild (#5443)
* fix: Change how starship version is determined
* Add STARSHIP_VERSION envar into CI for notarization
* More strict!
* Supress pushd/popd output
* Fix shellcheck issue with quoting
-rw-r--r-- | .github/workflows/release.yml | 1 | ||||
-rw-r--r-- | install/macos_packages/build_component_package.sh | 2 | ||||
-rw-r--r-- | install/macos_packages/common.sh | 20 |
3 files changed, 16 insertions, 7 deletions
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2baabd03d..20ef4ed0b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -176,6 +176,7 @@ jobs: env: KEYCHAIN_FILENAME: app-signing.keychain-db KEYCHAIN_ENTRY: AC_PASSWORD + STARSHIP_VERSION: ${{ needs.release_please.outputs.tag_name }} steps: - name: Checkout repository uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4 diff --git a/install/macos_packages/build_component_package.sh b/install/macos_packages/build_component_package.sh index 634f9f4d3..807e50567 100644 --- a/install/macos_packages/build_component_package.sh +++ b/install/macos_packages/build_component_package.sh @@ -87,4 +87,4 @@ trap - INT # Build the component package version="$(starship_version "$starship_program_file")" -pkgbuild --identifier com.starshipprompt.starship --version "$version" --root $pkgdir starship-component.pkg +pkgbuild --identifier com.starshipprompt.starship --version "$version" --root "$pkgdir" starship-component.pkg diff --git a/install/macos_packages/common.sh b/install/macos_packages/common.sh index f69d05d04..a7efb2c3a 100644 --- a/install/macos_packages/common.sh +++ b/install/macos_packages/common.sh @@ -11,12 +11,20 @@ starship_version() { if [ "$1" = "${1#/}" ]; then starship_program_file="./$starship_program_file" fi - if "$starship_program_file" -V 2>&1 >/dev/null; then - "$starship_program_file" -V | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+' + + # Try to get the version from three sources in the following order: + # - the STARSHIP_VERSION envar (usually set by the CI) + # - Running the binary file + # - By cutting out the first version tag in Cargo.toml + # These get increasingly fragile as we go down the list---ideally CI should + # always run with STARSHIP_VERSION set to avoid issues in determining version. + if [ "$STARSHIP_VERSION" != "" ]; then + echo "$STARSHIP_VERSION" | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+' + elif "$starship_program_file" -V >/dev/null 2>&1; then + "$starship_program_file" -V 2> /dev/null | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+' else - # try to get this information from Cargo.toml - pushd "$(git rev-parse --show-toplevel)" || true - grep '^version = \"\(.*\)\"' Cargo.toml | cut -f 2 -d '"' - popd + pushd "$(git rev-parse --show-toplevel)" &> /dev/null || true + grep '^version = \"\(.*\)\"' Cargo.toml | head -n 1 | cut -f 2 -d '"' | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+' + popd &> /dev/null || true fi } |