Skip to content

Commit de07844

Browse files
authored
Merge pull request #14 from hierynomus/fix_caching
Fix caching of Instruqt CLI by checking the latest tag
2 parents 4681069 + 7054234 commit de07844

File tree

1 file changed

+20
-31
lines changed

1 file changed

+20
-31
lines changed

setup/action.yml

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -39,54 +39,43 @@ runs:
3939
exit 1
4040
;;
4141
esac
42-
42+
- name: Determine version to install
43+
id: version
44+
shell: bash
45+
run: |
46+
if [[ "${{ inputs.version }}" == "latest" ]]; then
47+
VERSION=$(curl -s https://api.github.com/repos/instruqt/cli/releases/latest | grep '"tag_name":' | sed -E 's/.*"(v?[^"]+)".*/\1/')
48+
echo "version=$VERSION" >> $GITHUB_OUTPUT
49+
else
50+
echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT
51+
fi
4352
- name: Cache Instruqt CLI
4453
id: cache
4554
uses: actions/cache@v4
4655
with:
4756
path: ~/.local/bin/instruqt
48-
key: instruqt-cli-${{ inputs.version }}-${{ steps.platform.outputs.platform }}
57+
key: instruqt-cli-${{ steps.version.outputs.version }}-${{ steps.platform.outputs.platform }}
4958
restore-keys: |
50-
instruqt-cli-${{ inputs.version }}-
59+
instruqt-cli-${{ steps.version.outputs.version }}-
5160
instruqt-cli-
5261
5362
- name: Install Instruqt CLI
5463
id: install
5564
if: steps.cache.outputs.cache-hit != 'true'
5665
shell: bash
5766
env:
58-
VERSION: ${{ inputs.version }}
67+
VERSION: ${{ steps.version.outputs.version }}
5968
PLATFORM: ${{ steps.platform.outputs.platform }}
6069
run: |
6170
# Determine download URL
62-
if [[ "$VERSION" == "latest" ]]; then
63-
if [[ "$PLATFORM" == "linux" ]]; then
64-
download_url="https://github.com/instruqt/cli/releases/latest/download/instruqt-linux.zip"
65-
elif [[ "$PLATFORM" == "darwin-amd64" ]]; then
66-
download_url="https://github.com/instruqt/cli/releases/latest/download/instruqt-darwin-amd64.zip"
67-
elif [[ "$PLATFORM" == "darwin-arm64" ]]; then
68-
download_url="https://github.com/instruqt/cli/releases/latest/download/instruqt-darwin-arm64.zip"
69-
elif [[ "$PLATFORM" == "windows" ]]; then
70-
download_url="https://github.com/instruqt/cli/releases/latest/download/instruqt-windows.zip"
71-
fi
72-
else
73-
if [[ "$PLATFORM" == "linux" ]]; then
74-
download_url="https://github.com/instruqt/cli/releases/download/${VERSION}/instruqt-linux.zip"
75-
elif [[ "$PLATFORM" == "darwin-amd64" ]]; then
76-
download_url="https://github.com/instruqt/cli/releases/download/${VERSION}/instruqt-darwin-amd64.zip"
77-
elif [[ "$PLATFORM" == "darwin-arm64" ]]; then
78-
download_url="https://github.com/instruqt/cli/releases/download/${VERSION}/instruqt-darwin-arm64.zip"
79-
elif [[ "$PLATFORM" == "windows" ]]; then
80-
download_url="https://github.com/instruqt/cli/releases/download/${VERSION}/instruqt-windows.zip"
81-
fi
82-
fi
83-
71+
download_url="https://github.com/instruqt/cli/releases/download/${VERSION}/instruqt-${PLATFORM}.zip"
72+
8473
echo "Downloading from: $download_url"
85-
74+
8675
# Download and extract
8776
curl -L -o instruqt.zip "$download_url"
8877
unzip -q instruqt.zip
89-
78+
9079
# Install to local bin
9180
mkdir -p ~/.local/bin
9281
if [[ "$PLATFORM" == "windows" ]]; then
@@ -95,13 +84,13 @@ runs:
9584
mv instruqt ~/.local/bin/
9685
chmod +x ~/.local/bin/instruqt
9786
fi
98-
87+
9988
# Clean up
10089
rm instruqt.zip
101-
90+
10291
# Add to PATH
10392
echo "$HOME/.local/bin" >> $GITHUB_PATH
104-
93+
10594
# Get installed version
10695
version=$(~/.local/bin/instruqt version | sed 's/Version: //')
10796
echo "version=$version" >> $GITHUB_OUTPUT

0 commit comments

Comments
 (0)