From cc33c481563c3e56646acf29ff1f113576855747 Mon Sep 17 00:00:00 2001 From: imbroglius <163344413+imbroglius@users.noreply.github.com> Date: Tue, 30 Jul 2024 21:49:23 +0200 Subject: [PATCH] Create upload.sh --- upload.sh | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 upload.sh diff --git a/upload.sh b/upload.sh new file mode 100644 index 00000000..123fe636 --- /dev/null +++ b/upload.sh @@ -0,0 +1,70 @@ +#!/bin/bash + +echo +echo "--------------------------------------" +echo " AOSP 14.0 Uploadbot " +echo " by " +echo " ponces " +echo "--------------------------------------" +echo + +set -e + +BL=$PWD/imbroglios_gsi +BD=$HOME/builds +TAG="$(date +v%Y.%m.%d)" +GUSER="imbroglius" +GREPO="imbroglios_gsi" + +SKIPOTA=false +if [ "$1" == "--skip-ota" ]; then + SKIPOTA=true +fi + +createRelease() { + echo "--> Creating release $TAG" + res=$(curl -s -L -X POST \ + "https://github.com/repos/$GUSER/$GREPO/releases" \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer $IMBROGLIOTOKEN" \ + -d "{\"tag_name\":\"$TAG\",\"name\":\"AOSP 14.0 $TAG\",\"body\":\"## Changelog\n- ...\n\n## Notes\n- ...\",\"draft\":true}") + id=$(echo "$res" | jq -rc ".id") + echo +} + +uploadAssets() { + buildDate="$(date +%Y%m%d)" + find $BD/ -name "ImbrogliOS-*-14.0-$buildDate.img.xz" | while read file; do + echo "--> Uploading $(basename $file)" + curl -o /dev/null -s -L -X POST \ + "https://uploads.github.com/repos/$GUSER/$GREPO/releases/$id/assets?name=$(basename $file)" \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer $GITHUB_API_TOKEN" \ + -H "Content-Type: application/octet-stream" \ + -T "$file" + echo + done +} + +updateOta() { + echo "--> Updating OTA file" + pushd "$BL" + git add config/ota.json + git commit -m "build: Bump OTA to $TAG" + git push + popd + echo +} + +START=$(date +%s) + +createRelease +uploadAssets +[ "$SKIPOTA" = false ] && updateOta + +END=$(date +%s) +ELAPSEDM=$(($(($END-$START))/60)) +ELAPSEDS=$(($(($END-$START))-$ELAPSEDM*60)) + +echo "--> Uploadbot completed in $ELAPSEDM minutes and $ELAPSEDS seconds" +echo