fix version getter
All checks were successful
Test STACKIT Auth Action / test (push) Successful in 54s

This commit is contained in:
jaime merino 2026-04-29 09:25:17 +02:00
parent 2b97001a94
commit f3a84f1c5b

View file

@ -30,12 +30,6 @@ runs:
run: | run: |
VERSION="${{ inputs.cli-version }}" VERSION="${{ inputs.cli-version }}"
if [ "$VERSION" = "latest" ]; then
VERSION=$(curl -s https://api.github.com/repos/stackitcloud/stackit-cli/releases/latest | jq -r '.tag_name')
else
VERSION="v$VERSION"
fi
# Detect OS # Detect OS
OS=$(uname -s | tr '[:upper:]' '[:lower:]') OS=$(uname -s | tr '[:upper:]' '[:lower:]')
case "$OS" in case "$OS" in
@ -56,15 +50,22 @@ runs:
EXT="tar.gz" EXT="tar.gz"
if [ "$OS" = "windows" ]; then EXT="zip"; fi if [ "$OS" = "windows" ]; then EXT="zip"; fi
URL="https://github.com/stackitcloud/stackit-cli/releases/download/${VERSION}/stackit-cli_${VERSION}_${OS}_${ARCH}.${EXT}" if [ "$VERSION" = "latest" ]; then
TAG=$(curl -sL https://api.github.com/repos/stackitcloud/stackit-cli/releases/latest | jq -r '.tag_name')
VERSION=${TAG#v}
else
TAG="v$VERSION"
fi
echo "Downloading STACKIT CLI ${VERSION} for ${OS}/${ARCH}..." URL="https://github.com/stackitcloud/stackit-cli/releases/download/${TAG}/stackit-cli_${VERSION}_${OS}_${ARCH}.${EXT}"
echo "Downloading STACKIT CLI ${TAG} for ${OS}/${ARCH}..."
if [ "$OS" = "windows" ]; then if [ "$OS" = "windows" ]; then
curl -sL "$URL" -o stackit.zip curl -sfL "$URL" -o stackit.zip
unzip -q stackit.zip unzip -q stackit.zip
rm stackit.zip rm stackit.zip
else else
curl -sL "$URL" | tar -xz curl -sfL "$URL" | tar -xz
fi fi
if [ ! -f stackit ] && [ ! -f stackit.exe ]; then if [ ! -f stackit ] && [ ! -f stackit.exe ]; then
@ -97,13 +98,10 @@ runs:
SA_KEY_FILE=$(mktemp) SA_KEY_FILE=$(mktemp)
echo "$SA_KEY" > "$SA_KEY_FILE" echo "$SA_KEY" > "$SA_KEY_FILE"
# Configure the CLI to use the service account key
export STACKIT_SERVICE_ACCOUNT_KEY_PATH="$SA_KEY_FILE"
echo "Authenticating and retrieving access token..." echo "Authenticating and retrieving access token..."
# Construct command # Construct command
CMD="stackit auth activate-service-account --only-print-access-token" CMD="stackit auth activate-service-account --service-account-key-path $SA_KEY_FILE --only-print-access-token"
if [ -n "$PROJECT_ID" ]; then if [ -n "$PROJECT_ID" ]; then
CMD="$CMD --project-id $PROJECT_ID" CMD="$CMD --project-id $PROJECT_ID"
fi fi