From b7a184b26ba4e49ae13542ae8d5354fa62585d8a Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Tue, 6 May 2025 22:00:54 +0200 Subject: [PATCH] Add release script --- release.sh | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 release.sh diff --git a/release.sh b/release.sh new file mode 100644 index 0000000..8a65489 --- /dev/null +++ b/release.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +echo "Figuring out the tag..." +TAG=$(git describe --tags --exact-match 2>/dev/null || echo "") +if [ -z "$TAG" ]; then + # Get the latest tag + LATEST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1)) + # Increment the patch version + IFS='.' read -r -a VERSION_PARTS <<< "$LATEST_TAG" + VERSION_PARTS[2]=$((VERSION_PARTS[2]+1)) + TAG="${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.${VERSION_PARTS[2]}" + # Create a new tag + git tag $TAG +fi +echo "Tag: $TAG" + +echo "Building the thing..." +sed -i "s/## Version: .*/## Version: $TAG/" Heimdall.toc +sed -i "s/local VERSION = .*/local VERSION = \"$TAG\"/" Heimdall.lua +git add Heimdall.toc Heimdall.lua +git commit -m "Release $TAG" +git tag -f $TAG +git push origin $TAG + +rm Heimdall-${TAG}.zip +mkdir Heimdall +cp *.lua *.toc Heimdall +cp -r Modules Heimdall +cp -r Sounds Heimdall +cp -r Texture Heimdall +7z a Heimdall-${TAG}.zip Heimdall +rm -rf Heimdall + +echo "Creating a release..." +TOKEN="$GITEA_API_KEY" +GITEA="https://git.site.quack-lab.dev" +REPO="dave/wow-ABS" +# Create a release +RELEASE_RESPONSE=$(curl -s -X POST \ + -H "Authorization: token $TOKEN" \ + -H "Accept: application/json" \ + -H "Content-Type: application/json" \ + -d '{ + "tag_name": "'"$TAG"'", + "name": "'"$TAG"'", + "draft": false, + "prerelease": false + }' \ + $GITEA/api/v1/repos/$REPO/releases) + +# Extract the release ID +echo $RELEASE_RESPONSE +RELEASE_ID=$(echo $RELEASE_RESPONSE | awk -F'"id":' '{print $2+0; exit}') +echo "Release ID: $RELEASE_ID" + +echo "Uploading the things..." +curl -X POST \ + -H "Authorization: token $TOKEN" \ + -F "attachment=@Heimdall-${TAG}.zip" \ + "$GITEA/api/v1/repos/$REPO/releases/${RELEASE_ID}/assets?name=Heimdall-${TAG}.zip" +rm Heimdall-${TAG}.zip