Fix up the release to be a little more manual
This commit is contained in:
87
release.sh
87
release.sh
@@ -1,43 +1,58 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Default version increment
|
||||
DEFAULT_INCREMENT="0.0.1"
|
||||
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
|
||||
git push origin $TAG
|
||||
fi
|
||||
echo "Tag: $TAG"
|
||||
|
||||
# Get the increment parameter or use the default
|
||||
INCREMENT=${1:-$DEFAULT_INCREMENT}
|
||||
|
||||
# Function to increment the version
|
||||
increment_version() {
|
||||
local version=$1
|
||||
local increment=$2
|
||||
|
||||
IFS='.' read -r -a version_parts <<< "$version"
|
||||
IFS='.' read -r -a increment_parts <<< "$increment"
|
||||
|
||||
# Increment major, minor, and patch
|
||||
version_parts[0]=$((version_parts[0] + increment_parts[0]))
|
||||
version_parts[1]=$((version_parts[1] + increment_parts[1]))
|
||||
version_parts[2]=$((version_parts[2] + increment_parts[2]))
|
||||
|
||||
# Reset minor and patch if major is incremented
|
||||
if [ "${increment_parts[0]}" -gt 0 ]; then
|
||||
version_parts[1]=0
|
||||
version_parts[2]=0
|
||||
elif [ "${increment_parts[1]}" -gt 0 ]; then
|
||||
version_parts[2]=0
|
||||
fi
|
||||
|
||||
echo "${version_parts[0]}.${version_parts[1]}.${version_parts[2]}"
|
||||
}
|
||||
|
||||
CURRENT_VERSION=$(grep -oP '## Version: \K[0-9]+\.[0-9]+\.[0-9]+' Heimdall.toc)
|
||||
NEW_VERSION=$(increment_version "$CURRENT_VERSION" "$INCREMENT")
|
||||
echo "Building the thing..."
|
||||
sed -i "s/## Version: $CURRENT_VERSION/## Version: $NEW_VERSION/" Heimdall.toc
|
||||
sed -i "s/local VERSION = \"$CURRENT_VERSION\"/local VERSION = \"$NEW_VERSION\"/" Heimdall.lua
|
||||
|
||||
# Git operations
|
||||
git add Heimdall.lua Heimdall.toc
|
||||
git commit -m "Release $NEW_VERSION"
|
||||
git tag "$NEW_VERSION"
|
||||
rm Heimdall-${TAG}.zip
|
||||
mkdir Heimdall
|
||||
cp *.lua *.toc Heimdall
|
||||
cp -r Modules Heimdall
|
||||
cp -r Sounds Heimdall
|
||||
cp -r Texture Heimdall
|
||||
zip -r Heimdall-${TAG}.zip Heimdall
|
||||
rm -rf Heimdall
|
||||
|
||||
echo "Deployment complete. New version: $NEW_VERSION"
|
||||
echo "Creating a release..."
|
||||
TOKEN="$GITEA_API_KEY"
|
||||
GITEA="https://git.site.quack-lab.dev"
|
||||
REPO="dave/wow-heimdall"
|
||||
# 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
|
||||
|
Reference in New Issue
Block a user