Verified Commit fd4431f1 authored by Camil Staps's avatar Camil Staps 🚀

update.sh: drop --release-repo support (gitlab releases cannot have files...

update.sh: drop --release-repo support (gitlab releases cannot have files uploaded through API); add --release-directory instead
parent 1d99d132
Pipeline #15343 passed with stage
in 15 minutes and 39 seconds
#!/bin/bash #!/bin/bash
set -e
CLEAR_CACHE=-1 CLEAR_CACHE=-1
INTERACTIVE=1 INTERACTIVE=1
...@@ -13,10 +15,9 @@ while [ $# -gt 0 ]; do ...@@ -13,10 +15,9 @@ while [ $# -gt 0 ]; do
--clear-cache ) CLEAR_CACHE=1;; --clear-cache ) CLEAR_CACHE=1;;
--no-clear-cache ) CLEAR_CACHE=0;; --no-clear-cache ) CLEAR_CACHE=0;;
--huginn ) HUGINN="$2"; shift;; --huginn ) HUGINN="$2"; shift;;
--release-repo ) RELEASE_REPO="$2"; shift;; --release-directory ) RELEASE_DIRECTORY="$2"; shift;;
--github-token ) GITHUB_TOKEN="$2"; shift;;
-h|--help ) -h|--help )
echo "Usage: $0 [--[no-]interactive] [--[no-]clear-cache] [--huginn HUGINN_ADDRESS] [--release-repo USER/REPO] [--github-token TOKEN]" echo "Usage: $0 [--[no-]interactive] [--[no-]clear-cache] [--huginn HUGINN_ADDRESS] [--release-directory DIR]"
exit;; exit;;
* ) * )
echo "Unknown argument '$1'; use -h for help" echo "Unknown argument '$1'; use -h for help"
...@@ -45,7 +46,7 @@ sed -i "s/{{{COMMIT}}}/$COMMIT_INFO/g" "frontend/index.php" ...@@ -45,7 +46,7 @@ sed -i "s/{{{COMMIT}}}/$COMMIT_INFO/g" "frontend/index.php"
echo "Updating containers..." echo "Updating containers..."
sudo docker-compose build --force-rm --no-cache --pull &> /tmp/cloogle-build.log sudo stdbuf -o0 -e0 docker-compose build --force-rm --no-cache --pull &> /tmp/cloogle-build.log
RES=$? RES=$?
cat /tmp/cloogle-build.log cat /tmp/cloogle-build.log
if [ $RES -ne 0 ]; then if [ $RES -ne 0 ]; then
...@@ -76,31 +77,20 @@ else ...@@ -76,31 +77,20 @@ else
echo "Not clearing the cache." echo "Not clearing the cache."
fi fi
RESULTS="$(grep -A12 -F '| Table' /tmp/cloogle-build.log | sed 's/\x1b\[[0-9;]*m//g')"
if [[ "$HUGINN" != "" ]]; then if [[ "$HUGINN" != "" ]]; then
curl -s -d text="Cloogle build succeeded." "$HUGINN"; echo curl -s -d text="Cloogle build succeeded." "$HUGINN"; echo
fi fi
if [[ "$RELEASE_REPO" != "" ]]; then if [[ "$RELEASE_DIRECTORY" != "" ]]; then
timeout -k 10 10 sudo docker-compose exec -T backend cat types.json > /tmp/types.json
timeout -k 10 10 sudo docker-compose exec -T backend cat typetree.dot > /tmp/typetree.dot
DATE="$(date +%Y-%m-%d)" DATE="$(date +%Y-%m-%d)"
ID="$(curl -s -X POST \ THIS_RELEASE="$RELEASE_DIRECTORY/~$DATE"
-H "Content-Type:application/json" \ mkdir -p "$THIS_RELEASE"
-H "Authorization: token $GITHUB_TOKEN" "https://api.github.com/repos/$RELEASE_REPO/releases" \ rm -f "$RELEASE_DIRECTORY/latest"
-d "{\"tag_name\":\"$DATE\",\"name\":\"$DATE\",\"body\":\"Automatic update on $DATE.\\n\\n${RESULTS//$'\n'/\\n}\"}" | jq .id)" ln -s "~$DATE" "$RELEASE_DIRECTORY/latest"
if [[ "$ID" == "null" ]]; then sed 's/\x1b\[[0-9;]*m//g' /tmp/cloogle-build.log \
echo "Could not create release '$DATE'" | sed -n '/^\.\/builddb /{:a;n;/^Execution: /{p;b};p;ba}' \
else > "$THIS_RELEASE/build-log.txt"
curl -X POST \ timeout -k 10 10 sudo docker-compose exec -T backend cat types.json > "$THIS_RELEASE/types.json"
-H "Content-Type:text/json" \ timeout -k 10 10 sudo docker-compose exec -T backend cat typetree.dot > "$THIS_RELEASE/typetree.dot"
--data-binary @/tmp/types.json \
"https://uploads.github.com/repos/$RELEASE_REPO/releases/$ID/assets?name=types.json&access_token=$GITHUB_TOKEN"
curl -X POST \
-H "Content-Type:text/plain" \
--data-binary @/tmp/typetree.dot \
"https://uploads.github.com/repos/$RELEASE_REPO/releases/$ID/assets?name=typetree.dot&access_token=$GITHUB_TOKEN"
echo
fi
fi fi
echo "--> Cloogle build succeeded." echo "--> Cloogle build succeeded."
echo "$RESULTS" echo "$RESULTS"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment