@@ -5,59 +5,47 @@ GREEN='\033[0;32m'
5
5
NC=' \033[0m' # No Color
6
6
7
7
REPO=" HexmosTech/Lama2"
8
- ARTIFACT_NAME=" l2-binary "
8
+ ARTIFACT_NAME=" l2"
9
9
10
- # Function to get the latest workflow run ID
11
- get_latest_workflow_run_id () {
10
+ get_latest_run_id () {
12
11
curl -s " https://api.github.com/repos/$REPO /actions/runs?status=success" |
13
12
jq ' .workflow_runs[0].id'
14
13
}
15
14
16
- # Function to get the artifact download URL
17
- get_artifact_url () {
18
- local run_id=$1
19
- curl -s " https://api.github.com/repos/$REPO /actions/runs/$run_id /artifacts" |
20
- jq -r " .artifacts[] | select(.name == \" $ARTIFACT_NAME \" ) | .archive_download_url"
21
- }
22
-
23
- # Main installation process
24
- main () {
25
- echo " Fetching the latest successful workflow run..."
26
- run_id=$( get_latest_workflow_run_id)
27
- echo " Latest workflow run ID: $run_id "
28
-
15
+ download_artifact () {
16
+ run_id=$( get_latest_run_id)
29
17
if [ -z " $run_id " ]; then
30
- echo -e " ${RED} Failed to fetch the latest workflow run. ${NC} "
18
+ echo -e " ${RED} Failed to get the latest successful run ID ${NC} "
31
19
exit 1
32
20
fi
33
21
34
- echo " Getting artifact download URL... "
35
- artifact_url= $( get_artifact_url $run_id )
22
+ artifact_url= $( curl -s " https://api.github.com/repos/ $REPO /actions/runs/ $run_id /artifacts " |
23
+ jq -r " .artifacts[] | select(.name == \" $ARTIFACT_NAME \" ) | .archive_download_url " )
36
24
37
25
if [ -z " $artifact_url " ]; then
38
- echo -e " ${RED} Failed to get artifact download URL. ${NC} "
26
+ echo -e " ${RED} Failed to find the artifact download URL${NC} "
39
27
exit 1
40
28
fi
41
29
42
- echo " Downloading l2 binary... "
30
+ echo " Downloading artifact from $artifact_url "
43
31
curl -L -o /tmp/l2.zip " $artifact_url "
32
+
33
+ unzip /tmp/l2.zip -d /tmp
34
+ rm /tmp/l2.zip
35
+ }
44
36
45
- echo " Extracting l2 binary..."
46
- unzip -o /tmp/l2.zip -d /tmp
47
-
48
- echo " Installing l2 binary..."
49
- sudo mv /tmp/l2 /usr/local/bin/l2
37
+ install_binary () {
38
+ sudo rm -f /usr/local/bin/l2 /usr/bin/l2
39
+ sudo mv /tmp/l2 /usr/local/bin
50
40
sudo chmod +x /usr/local/bin/l2
51
-
52
- if l2 > /dev/null 2>&1 ; then
53
- echo -e " ${GREEN} Successfully installed Lama2; Type 'l2 <api_file>' to invoke Lama2${NC} "
54
- else
55
- echo -e " ${RED} Failure in installation; please report issue at github.com/HexmosTech/Lama2${NC} "
56
- fi
57
-
58
- # Clean up
59
- rm /tmp/l2.zip
60
41
}
61
42
62
- # Run the main function
63
- main
43
+ # Main execution
44
+ download_artifact
45
+ install_binary
46
+
47
+ if l2 --version > /dev/null 2>&1 ; then
48
+ echo -e " ${GREEN} Successfully installed Lama2; Type 'l2 <api_file>' to invoke Lama2${NC} "
49
+ else
50
+ echo -e " ${RED} Failure in installation; please report issue at github.com/HexmosTech/Lama2${NC} "
51
+ fi
0 commit comments