Skip to content

Commit

Permalink
fix: github action release download from api url
Browse files Browse the repository at this point in the history
  • Loading branch information
jaromil committed Dec 28, 2024
1 parent f0455e1 commit 2af1106
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions build/pack-examples.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
set -e
#set -x
set -x

# this script is designed to run on GNU/Linux
# it will generate a cjit-demo archive usable on all platforms
Expand All @@ -11,14 +11,20 @@ function fetch() {
}
out="$1"
url="$2"
REPO_OWNER="$3"
REPO_NAME="$4"
TAG="$5"
FILE_NAME="$out"
mkdir -p ${odir}
if [ -r ${odir}/${out} ]; then
>&2 echo "Found : ${odir}/${out}"
else
>&2 echo "Download: ${odir}/${out}"
if [ "$GITHUB_ACTIONS" == "true" ]; then
curl -sL -H "Authorization: token $GITHUB_TOKEN" \
--output ${odir}/${out} ${url}
API_URL="https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/releases/tags/$TAG"
DOWNLOAD_URL=$(curl -s -H "Authorization: token $GITHUB_TOKEN" $API_URL | jq -r ".assets[] | select(.name==\"$FILE_NAME\") | .browser_download_url")
curl -L -H "Authorization: token $GITHUB_TOKEN" \
-o $FILE_NAME $DOWNLOAD_URL
else
curl -sL --output ${odir}/${out} ${url}
fi
Expand All @@ -43,10 +49,12 @@ cp dl/termbox2.h cjit-demo/include
mkdir -p cjit-demo/include/SDL2

# SDL2
org=libsdl-org
proj=SDL
ver=2.30.10
file=SDL2-${ver}-win32-x64.zip
url="https://github.com/libsdl-org/SDL/releases/download/release-${ver}"
fetch ${file} ${url}/${file}
fetch ${file} ${url}/${file} ${org} ${proj} release-${ver}
[ -r cjit-demo/SDL2.dll ] || unzip -q -d cjit-demo ${file} SDL2.dll
file=SDL2-${ver}
fetch ${file}.zip ${url}/${file}.zip
Expand All @@ -57,10 +65,11 @@ fetch ${file}.zip ${url}/${file}.zip
}

# SDL2_image
proj=SDL_image
ver=2.8.3
file=SDL2_image-${ver}-win32-x64.zip
url="https://github.com/libsdl-org/SDL_image/releases/download/release-${ver}"
fetch ${file} ${url}/${file}
fetch ${file} ${url}/${file} ${org} ${proj} release-${ver}
[ -r cjit-demo/SDL2_image.dll ] ||
unzip -q -d cjit-demo ${file} SDL2_image.dll
file=SDL2_image-${ver}
Expand All @@ -72,10 +81,11 @@ fetch ${file}.zip ${url}/${file}.zip
}

# SDL2_ttf
proj=SDL_ttf
ver=2.22.0
url="https://github.com/libsdl-org/SDL_ttf/releases/download/release-${ver}"
file=SDL2_ttf-${ver}-win32-x64.zip
fetch ${file} ${url}/${file}
fetch ${file} ${url}/${file} ${org} ${proj} release-${ver}
[ -r cjit-demo/SDL2_ttf.dll ] ||
unzip -q -d cjit-demo ${file} SDL2_ttf.dll
file=SDL2_ttf-${ver}
Expand All @@ -86,10 +96,12 @@ fetch ${file}.zip ${url}/${file}.zip
rm -rf /tmp/${file}
}

org=nigels-com
proj=glew
ver=2.2.0
url="https://github.com/nigels-com/glew/releases/download/glew-${ver}"
file="glew-${ver}-win32.zip"
fetch ${file} ${url}/${file}
fetch ${file} ${url}/${file} ${org} ${proj} glew-${ver}
[ -r cjit-demo/glew32.dll ] || {
unzip -q -d /tmp ${file}
mv /tmp/glew-${ver}/bin/Release/x64/glew32.dll cjit-demo/
Expand Down

0 comments on commit 2af1106

Please sign in to comment.