Skip to content

Commit

Permalink
installer: cleanup & fix CI/CD issues caused by rate limits in the Gi…
Browse files Browse the repository at this point in the history
…thub API
  • Loading branch information
Wertzui123 committed Jul 23, 2024
1 parent 190f880 commit 1cf9610
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 69 deletions.
17 changes: 13 additions & 4 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ jobs:
apt-get update
apt-get install --quiet -y git jq curl unzip
- name: Install ASPL
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd $GITHUB_WORKSPACE
./install_ci.sh
./install.sh
- name: Install runtime dependencies
run: |
apt-get update
Expand Down Expand Up @@ -82,9 +84,11 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- name: Install ASPL
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd $GITHUB_WORKSPACE
./install_ci.sh
./install.sh
- name: Install runtime dependencies
run: |
brew install glfw # for the graphics module
Expand Down Expand Up @@ -118,9 +122,11 @@ jobs:
apt-get update
apt-get install --quiet -y git jq curl unzip xz-utils build-essential
- name: Install ASPL
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd $GITHUB_WORKSPACE
./install_ci.sh
./install.sh
# - name: Delete template (macOS x86_64)
# run: |
# rm templates/macos/x86_64/Template
Expand Down Expand Up @@ -292,8 +298,11 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- name: Install ASPL
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
$GITHUB_WORKSPACE/install_ci.sh
cd $GITHUB_WORKSPACE
./install.sh
- name: Run tests
run: |
cd $GITHUB_WORKSPACE
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- name: Install ASPL
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd $GITHUB_WORKSPACE
./install_ci.sh
./install.sh
- name: Generate docs
run: |
cd $GITHUB_WORKSPACE
Expand Down
46 changes: 27 additions & 19 deletions install.bat
Original file line number Diff line number Diff line change
@@ -1,48 +1,56 @@
@echo off
setlocal enabledelayedexpansion

FOR /F "tokens=*" %%g IN ('git config --get remote.origin.url') do (SET remote=%%g)
echo %remote% | findstr /C:"github.com/aspl-lang/aspl" > nul && (
git "pull" "origin" "main"
git pull origin main
) || (
git "clone" "https://github.com/aspl-lang/aspl.git"
cd "aspl"
git clone https://github.com/aspl-lang/aspl.git
cd aspl
)

curl -L -o jq.exe https://github.com/stedolan/jq/releases/latest/download/jq-win64.exe

(curl -s https://api.github.com/repos/aspl-lang/cd/contents/latest.txt | jq -r .content) > sha.txt
IF DEFINED GITHUB_TOKEN (
SET AUTH_HEADER=Authorization: token %GITHUB_TOKEN%
) ELSE (
SET AUTH_HEADER=
)

curl -s -H "%AUTH_HEADER%" https://api.github.com/repos/aspl-lang/cd/contents/latest.txt | jq -r .content > sha.txt
certutil -decode sha.txt sha_decoded.txt
SET /p SHA=<sha_decoded.txt
DEL sha.txt
DEL sha_decoded.txt
SET CURL=curl https://api.github.com/repos/aspl-lang/cd/releases

if %PROCESSOR_ARCHITECTURE% == AMD64 (
IF "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
SET EXECUTABLE=aspl_windows_x86_64.exe
)
if %PROCESSOR_ARCHITECTURE% == IA64 (
) ELSE IF "%PROCESSOR_ARCHITECTURE%"=="IA64" (
SET EXECUTABLE=aspl_windows_x86_64.exe
)
if %PROCESSOR_ARCHITECTURE% == ARM64 (
) ELSE IF "%PROCESSOR_ARCHITECTURE%"=="ARM64" (
SET EXECUTABLE=aspl_windows_arm64.exe
)
if not defined EXECUTABLE (
) ELSE (
echo Unsupported architecture
exit /b 1
)

(%CURL%/tags/SHA-%SHA% | jq .assets | jq ".[] | select(.name == \"%EXECUTABLE%\").id") > id.txt
curl -H "%AUTH_HEADER%" https://api.github.com/repos/aspl-lang/cd/releases/tags/SHA-%SHA% -s | jq .assets | jq ".[] | select(.name == \"%EXECUTABLE%\").id" > id.txt
SET /p ASSET_ID=<id.txt
%CURL%/assets/%ASSET_ID% -LJOH "Accept: application/octet-stream"
DEL id.txt
echo Downloading %EXECUTABLE% (%ASSET_ID%):
curl -H "%AUTH_HEADER%" -LJOH "Accept: application/octet-stream" https://api.github.com/repos/aspl-lang/cd/releases/assets/%ASSET_ID%
rename %EXECUTABLE% aspl.exe
setx PATH "%PATH%;%CD%"

(%CURL%/tags/SHA-%SHA% | jq .assets | jq ".[] | select(.name == \"templates.zip\").id") > id.txt
echo Make the `aspl` command available everywhere (by adding it to the PATH?)? (y/n):
set /p choice=
if /i "%choice%"=="y" setx PATH "%PATH%;%CD%"

curl -H "%AUTH_HEADER%" https://api.github.com/repos/aspl-lang/cd/releases/tags/SHA-%SHA% -s | jq .assets | jq ".[] | select(.name == \"templates.zip\").id" > id.txt
SET /p ASSET_ID=<id.txt
DEL id.txt
%CURL%/assets/%ASSET_ID% -LJOH "Accept: application/octet-stream"
tar -xf "templates.zip"
DEL "templates.zip"
echo Downloading templates.zip (%ASSET_ID%):
curl -H "%AUTH_HEADER%" -LJOH "Accept: application/octet-stream" https://api.github.com/repos/aspl-lang/cd/releases/assets/%ASSET_ID%
tar -xf templates.zip
DEL templates.zip

DEL jq.exe
31 changes: 20 additions & 11 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@ else
git clone https://github.com/aspl-lang/aspl.git
cd aspl
fi
SHA=$(curl -s https://api.github.com/repos/aspl-lang/cd/contents/latest.txt -s | jq -r '.content' | base64 -d)

if [ -n "$GITHUB_TOKEN" ]; then
AUTH_HEADER="Authorization: token $GITHUB_TOKEN"
else
AUTH_HEADER=""
fi

SHA=$(curl -s -H "$AUTH_HEADER" https://api.github.com/repos/aspl-lang/cd/contents/latest.txt | jq -r '.content' | base64 -d)

if [ "$(uname)" = "Darwin" ]; then
if [ "$(uname -m)" = "x86_64" ]; then
EXECUTABLE=aspl_macos_x86_64
Expand Down Expand Up @@ -34,25 +42,26 @@ else
exit 1
fi

CURL="curl https://api.github.com/repos/aspl-lang/cd/releases"
ASSET_ID=$(eval "$CURL/tags/SHA-$SHA -s" | jq .assets | jq '.[] | select(.name == "'$EXECUTABLE'").id')
CURL="curl -s -H '$AUTH_HEADER' https://api.github.com/repos/aspl-lang/cd/releases"
ASSET_ID=$(eval "$CURL/tags/SHA-$SHA" | jq .assets | jq '.[] | select(.name == "'$EXECUTABLE'").id')
echo "Downloading $EXECUTABLE ($ASSET_ID):"
eval "$CURL/assets/$ASSET_ID -LJOH 'Accept: application/octet-stream' --progress-bar"

mv $EXECUTABLE aspl
chmod +x aspl

read -r -n 1 -p "Make aspl publicly avaiable by creating symlink in /usr/local/bin ? (Y/n): " choice
read -r -n 1 -p "Make the \`aspl\` command available everywhere (by creating a symlink in /usr/local/bin)? (y/n): " choice
printf "\n"
case "$choice" in
''|y|Y ) echo "Creating link"; sudo ln -fs $PWD/aspl /usr/local/bin/aspl;;
* ) echo "Skiping...";;
case "$choice" in
'' | y | Y)
echo "Creating link"
sudo ln -fs $PWD/aspl /usr/local/bin/aspl
;;
*) echo "Skiping..." ;;
esac

CURL="curl https://api.github.com/repos/aspl-lang/cd/releases"
ASSET_ID=$(eval "$CURL/tags/SHA-$SHA -s" | jq .assets | jq '.[] | select(.name == "templates.zip").id')
ASSET_ID=$(eval "$CURL/tags/SHA-$SHA" | jq .assets | jq '.[] | select(.name == "templates.zip").id')
echo "Downloading templates.zip ($ASSET_ID):"
eval "$CURL/assets/$ASSET_ID -LJOH 'Accept: application/octet-stream' --progress-bar"
unzip -of templates.zip
unzip -o templates.zip
rm templates.zip

34 changes: 0 additions & 34 deletions install_ci.sh

This file was deleted.

0 comments on commit 1cf9610

Please sign in to comment.