From 4d1320161a8ff0bf25d8b7d01c73c3e6e75ff9fa Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Sat, 6 Dec 2025 01:53:33 +0100 Subject: [PATCH] Add a release script --- release.sh | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 release.sh diff --git a/release.sh b/release.sh new file mode 100644 index 000000000..913af58bf --- /dev/null +++ b/release.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +set -e + +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) 2>/dev/null || echo "v0.0.0") + # Remove 'v' prefix if present + LATEST_TAG=${LATEST_TAG#v} + # Increment the patch version + IFS='.' read -r -a VERSION_PARTS <<< "$LATEST_TAG" + VERSION_PARTS[2]=$((VERSION_PARTS[2]+1)) + TAG="v${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.${VERSION_PARTS[2]}" + # Create a new tag + git tag $TAG + git push origin $TAG +fi +echo "Tag: $TAG" + +echo "Building the binary..." +./build.sh + +echo "Creating release zip..." +ZIP="pyfa-${TAG}-win.zip" +cd dist/pyfa +zip -r "../../${ZIP}" . +cd ../.. + +echo "Creating a release..." +TOKEN="$GITEA_API_KEY" +GITEA="https://git.site.quack-lab.dev" +REPO="dave/pyfa" + +# 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 zip..." +curl -X POST \ + -H "Authorization: token $TOKEN" \ + -F "attachment=@${ZIP}" \ + "$GITEA/api/v1/repos/$REPO/releases/${RELEASE_ID}/assets?name=${ZIP}" + +echo "Release complete! ${ZIP} uploaded to ${TAG}"