Files
starship/install/macos_packages/common.sh
T
Shu Kutsuzawa 6e6664dea6 ci: add install script workflow (#7159)
* ci: add install script workflow

Add GitHub Actions workflow to test install.sh script.

This prevents regressions like the one reported in issue #7133 where
changes to the install script broke the recommended installation method.

The workflow includes:
- shellcheck for script linting (temporarily excludes SC3045)
- Integration test using curl piped to sh as documented on starship.rs

Signed-off-by: cappyzawa <cappyzawa@gmail.com>

* fixup! ci: add install script workflow

Signed-off-by: cappyzawa <cappyzawa@gmail.com>

* fixup! ci: add install script workflow

Signed-off-by: cappyzawa <cappyzawa@gmail.com>

* ci: add shfmt check and format install scripts

Add shfmt job to install-script workflow for consistent shell script
formatting. Apply shfmt to all scripts under install/ directory.

Signed-off-by: cappyzawa <cappyzawa@gmail.com>

---------

Signed-off-by: cappyzawa <cappyzawa@gmail.com>
2025-12-28 21:19:25 +01:00

31 lines
1.0 KiB
Bash

#!/bin/bash
error() {
echo "[ERROR]: $1"
exit 1
}
starship_version() {
starship_program_file="$1"
# Check if this is a relative path: if so, prepend './' to it
if [ "$1" = "${1#/}" ]; then
starship_program_file="./$starship_program_file"
fi
# 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
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
}