Skip to content

Commit f228b86

Browse files
committed
[ANE-2484] Download ficus in vendor_download.sh
1 parent 44683e9 commit f228b86

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

vendor_download.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,23 @@ mkdir -p vendor-bins
3232

3333
ASSET_POSTFIX=""
3434
THEMIS_ASSET_POSTFIX=""
35+
FICUS_ASSET_POSTFIX=""
3536
LERNIE_ASSET_POSTFIX=""
3637
CIRCE_ASSET_POSTFIX=""
3738
case "$(uname -s)" in
3839
Darwin)
3940
case "$(uname -m)" in
4041
arm64)
4142
ASSET_POSTFIX="darwin-arm64"
43+
FICUS_ASSET_POSTFIX="aarch64-apple-darwin.tar.gz"
4244
LERNIE_ASSET_POSTFIX="aarch64-macos"
4345
THEMIS_ASSET_POSTFIX="darwin-arm64"
4446
CIRCE_ASSET_POSTFIX="aarch64-apple-darwin"
4547
;;
4648

4749
*)
4850
ASSET_POSTFIX="darwin-amd64"
51+
FICUS_ASSET_POSTFIX="x86_64-apple-darwin.tar.gz"
4952
LERNIE_ASSET_POSTFIX="x86_64-macos"
5053
THEMIS_ASSET_POSTFIX="darwin-amd64"
5154
CIRCE_ASSET_POSTFIX="x86_64-apple-darwin"
@@ -58,13 +61,15 @@ case "$(uname -s)" in
5861
aarch64)
5962
ASSET_POSTFIX="linux"
6063
THEMIS_ASSET_POSTFIX="linux-arm64"
64+
FICUS_ASSET_POSTFIX="aarch64-linux.tar.gz"
6165
LERNIE_ASSET_POSTFIX="aarch64-linux"
6266
CIRCE_ASSET_POSTFIX="aarch64-unknown-linux-musl"
6367
;;
6468

6569
*)
6670
ASSET_POSTFIX="linux"
6771
THEMIS_ASSET_POSTFIX="linux-amd64"
72+
FICUS_ASSET_POSTFIX="x86_64-linux.tar.gz"
6873
LERNIE_ASSET_POSTFIX="x86_64-linux"
6974
CIRCE_ASSET_POSTFIX="x86_64-unknown-linux-musl"
7075
;;
@@ -74,6 +79,7 @@ case "$(uname -s)" in
7479
echo "Warn: Assuming $(uname -s) is Windows"
7580
ASSET_POSTFIX="windows.exe"
7681
THEMIS_ASSET_POSTFIX="windows-amd64"
82+
FICUS_ASSET_POSTFIX="x86_64-windows.exe.zip"
7783
LERNIE_ASSET_POSTFIX="x86_64-windows.exe"
7884
CIRCE_ASSET_POSTFIX="x86_64-pc-windows-msvc"
7985
;;
@@ -142,6 +148,47 @@ echo "Lernie download successful"
142148

143149
rm $LERNIE_RELEASE_JSON
144150

151+
# Download latest release of Ficus
152+
153+
echo "Downloading ficus binary from latest release"
154+
FICUS_RELEASE_JSON=vendor-bins/ficus-release.json
155+
curl -sSL \
156+
-H "Authorization: token $GITHUB_TOKEN" \
157+
-H "Accept: application/vnd.github.v3.raw" \
158+
https://api.github.com/repos/fossas/ficus/releases/latest > $FICUS_RELEASE_JSON
159+
160+
FICUS_TAG=$(jq -cr ".name" $FICUS_RELEASE_JSON)
161+
# Strip the leading 'v' off of the tag
162+
FICUS_VERSION="${FICUS_TAG/#v/}"
163+
FILTER=".name == \"ficus-$FICUS_ASSET_POSTFIX\""
164+
jq -c ".assets | map({url: .url, name: .name}) | map(select($FILTER)) | .[]" $FICUS_RELEASE_JSON | while read -r ASSET; do
165+
URL="$(echo "$ASSET" | jq -c -r '.url')"
166+
NAME="$(echo "$ASSET" | jq -c -r '.name')"
167+
OUTPUT="$(echo vendor-bins/"$NAME" | sed 's/-'"$FICUS_VERSION"'-'$FICUS_ASSET_POSTFIX'$//')"
168+
169+
echo "Downloading '$NAME' to '$OUTPUT'"
170+
curl -sL -H "Authorization: token $GITHUB_TOKEN" -H "Accept: application/octet-stream" -s "$URL" > "$OUTPUT"
171+
172+
case "$(uname -s)" in
173+
Darwin)
174+
tar -zxf $OUTPUT --strip-components 1 --exclude LICENSE --exclude README.md --directory vendor-bins
175+
;;
176+
Linux)
177+
tar -zxf $OUTPUT --strip-components 1 --exclude LICENSE --exclude README.md --directory vendor-bins
178+
;;
179+
*)
180+
echo "Warn: Assuming $(uname -s) is Windows"
181+
unzip $OUTPUT ficus.exe -d vendor-bins
182+
;;
183+
esac
184+
rm $OUTPUT
185+
186+
187+
done
188+
echo "Ficus download successful"
189+
190+
rm $FICUS_RELEASE_JSON
191+
145192
# Download latest release of Circe
146193

147194
echo "Downloading circe binary from latest release"

0 commit comments

Comments
 (0)