Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 20 additions & 31 deletions setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,54 +39,43 @@ runs:
exit 1
;;
esac

- name: Determine version to install
id: version
shell: bash
run: |
if [[ "${{ inputs.version }}" == "latest" ]]; then
VERSION=$(curl -s https://api.github.com/repos/instruqt/cli/releases/latest | grep '"tag_name":' | sed -E 's/.*"(v?[^"]+)".*/\1/')
echo "version=$VERSION" >> $GITHUB_OUTPUT
else
echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT
fi
- name: Cache Instruqt CLI
id: cache
uses: actions/cache@v4
with:
path: ~/.local/bin/instruqt
key: instruqt-cli-${{ inputs.version }}-${{ steps.platform.outputs.platform }}
key: instruqt-cli-${{ steps.version.outputs.version }}-${{ steps.platform.outputs.platform }}
restore-keys: |
instruqt-cli-${{ inputs.version }}-
instruqt-cli-${{ steps.version.outputs.version }}-
instruqt-cli-

- name: Install Instruqt CLI
id: install
if: steps.cache.outputs.cache-hit != 'true'
shell: bash
env:
VERSION: ${{ inputs.version }}
VERSION: ${{ steps.version.outputs.version }}
PLATFORM: ${{ steps.platform.outputs.platform }}
run: |
# Determine download URL
if [[ "$VERSION" == "latest" ]]; then
if [[ "$PLATFORM" == "linux" ]]; then
download_url="https://github.com/instruqt/cli/releases/latest/download/instruqt-linux.zip"
elif [[ "$PLATFORM" == "darwin-amd64" ]]; then
download_url="https://github.com/instruqt/cli/releases/latest/download/instruqt-darwin-amd64.zip"
elif [[ "$PLATFORM" == "darwin-arm64" ]]; then
download_url="https://github.com/instruqt/cli/releases/latest/download/instruqt-darwin-arm64.zip"
elif [[ "$PLATFORM" == "windows" ]]; then
download_url="https://github.com/instruqt/cli/releases/latest/download/instruqt-windows.zip"
fi
else
if [[ "$PLATFORM" == "linux" ]]; then
download_url="https://github.com/instruqt/cli/releases/download/${VERSION}/instruqt-linux.zip"
elif [[ "$PLATFORM" == "darwin-amd64" ]]; then
download_url="https://github.com/instruqt/cli/releases/download/${VERSION}/instruqt-darwin-amd64.zip"
elif [[ "$PLATFORM" == "darwin-arm64" ]]; then
download_url="https://github.com/instruqt/cli/releases/download/${VERSION}/instruqt-darwin-arm64.zip"
elif [[ "$PLATFORM" == "windows" ]]; then
download_url="https://github.com/instruqt/cli/releases/download/${VERSION}/instruqt-windows.zip"
fi
fi

download_url="https://github.com/instruqt/cli/releases/download/${VERSION}/instruqt-${PLATFORM}.zip"

echo "Downloading from: $download_url"

# Download and extract
curl -L -o instruqt.zip "$download_url"
unzip -q instruqt.zip

# Install to local bin
mkdir -p ~/.local/bin
if [[ "$PLATFORM" == "windows" ]]; then
Expand All @@ -95,13 +84,13 @@ runs:
mv instruqt ~/.local/bin/
chmod +x ~/.local/bin/instruqt
fi

# Clean up
rm instruqt.zip

# Add to PATH
echo "$HOME/.local/bin" >> $GITHUB_PATH

# Get installed version
version=$(~/.local/bin/instruqt version | sed 's/Version: //')
echo "version=$version" >> $GITHUB_OUTPUT
Expand Down
Loading