From 70542344295fedcbb1cbe27ef5d9e0d012c78d74 Mon Sep 17 00:00:00 2001 From: Jeroen van Erp Date: Thu, 11 Dec 2025 12:09:46 +0100 Subject: [PATCH] Fix caching of Instruqt CLI by checking the latest tag --- setup/action.yml | 51 +++++++++++++++++++----------------------------- 1 file changed, 20 insertions(+), 31 deletions(-) diff --git a/setup/action.yml b/setup/action.yml index 9e93037..a1a6a1e 100644 --- a/setup/action.yml +++ b/setup/action.yml @@ -39,15 +39,24 @@ 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 @@ -55,38 +64,18 @@ runs: 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 @@ -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