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
set -e
CLEAR_CACHE=-1
INTERACTIVE=1
......@@ -13,10 +15,9 @@ while [ $# -gt 0 ]; do
--clear-cache ) CLEAR_CACHE=1;;
--no-clear-cache ) CLEAR_CACHE=0;;
--huginn ) HUGINN="$2"; shift;;
--release-repo ) RELEASE_REPO="$2"; shift;;
--github-token ) GITHUB_TOKEN="$2"; shift;;
--release-directory ) RELEASE_DIRECTORY="$2"; shift;;
-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;;
* )
echo "Unknown argument '$1'; use -h for help"
......@@ -45,7 +46,7 @@ sed -i "s/{{{COMMIT}}}/$COMMIT_INFO/g" "frontend/index.php"
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=$?
cat /tmp/cloogle-build.log
if [ $RES -ne 0 ]; then
......@@ -76,31 +77,20 @@ else
echo "Not clearing the cache."
fi
RESULTS="$(grep -A12 -F '| Table' /tmp/cloogle-build.log | sed 's/\x1b\[[0-9;]*m//g')"
if [[ "$HUGINN" != "" ]]; then
curl -s -d text="Cloogle build succeeded." "$HUGINN"; echo
fi
if [[ "$RELEASE_REPO" != "" ]]; 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
if [[ "$RELEASE_DIRECTORY" != "" ]]; then
DATE="$(date +%Y-%m-%d)"
ID="$(curl -s -X POST \
-H "Content-Type:application/json" \
-H "Authorization: token $GITHUB_TOKEN" "https://api.github.com/repos/$RELEASE_REPO/releases" \
-d "{\"tag_name\":\"$DATE\",\"name\":\"$DATE\",\"body\":\"Automatic update on $DATE.\\n\\n${RESULTS//$'\n'/\\n}\"}" | jq .id)"
if [[ "$ID" == "null" ]]; then
echo "Could not create release '$DATE'"
else
curl -X POST \
-H "Content-Type:text/json" \
--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
THIS_RELEASE="$RELEASE_DIRECTORY/~$DATE"
mkdir -p "$THIS_RELEASE"
rm -f "$RELEASE_DIRECTORY/latest"
ln -s "~$DATE" "$RELEASE_DIRECTORY/latest"
sed 's/\x1b\[[0-9;]*m//g' /tmp/cloogle-build.log \
| sed -n '/^\.\/builddb /{:a;n;/^Execution: /{p;b};p;ba}' \
> "$THIS_RELEASE/build-log.txt"
timeout -k 10 10 sudo docker-compose exec -T backend cat types.json > "$THIS_RELEASE/types.json"
timeout -k 10 10 sudo docker-compose exec -T backend cat typetree.dot > "$THIS_RELEASE/typetree.dot"
fi
echo "--> Cloogle build succeeded."
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