84 lines
2.0 KiB
Bash
Executable File
84 lines
2.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
VERSION_FILE="VERSION"
|
|
|
|
if [ ! -f "$VERSION_FILE" ]; then
|
|
echo "Error: $VERSION_FILE not found" >&2
|
|
exit 1
|
|
fi
|
|
|
|
current=$(cat "$VERSION_FILE")
|
|
echo "Current version: $current"
|
|
|
|
IFS='.' read -r major minor patch <<< "$current"
|
|
|
|
if [ "${1:-}" = "--increment" ]; then
|
|
patch=$((patch + 1))
|
|
new_version="${major}.${minor}.${patch}"
|
|
echo "Auto-incrementing to: $new_version"
|
|
else
|
|
echo "Increment version? [y/N]"
|
|
read -r answer
|
|
if [[ "$answer" =~ ^[Yy] ]]; then
|
|
patch=$((patch + 1))
|
|
new_version="${major}.${minor}.${patch}"
|
|
echo "New version: $new_version"
|
|
else
|
|
new_version="$current"
|
|
echo "Keeping version: $new_version"
|
|
fi
|
|
fi
|
|
|
|
echo "$new_version" > "$VERSION_FILE"
|
|
|
|
echo "Building arrman v${new_version}..."
|
|
go build -ldflags "-X main.Version=${new_version}" -o arrman .
|
|
|
|
echo "Build successful: ./arrman v${new_version}"
|
|
|
|
# --- Git commit & push ---
|
|
echo ""
|
|
echo "Committing changes..."
|
|
git add -A
|
|
if git diff --cached --quiet; then
|
|
echo "No changes to commit, skipping."
|
|
else
|
|
git commit -m "Release v${new_version}"
|
|
echo "Committed."
|
|
fi
|
|
|
|
echo "Pushing to origin..."
|
|
git push origin main
|
|
|
|
# --- Git tag & Gitea release ---
|
|
tag="v${new_version}"
|
|
|
|
if git tag -l "${tag}" | grep -q "^${tag}$"; then
|
|
echo "Warning: Tag ${tag} already exists, skipping tag, push, and release creation."
|
|
else
|
|
echo "Creating tag ${tag}..."
|
|
git tag -a "${tag}" -m "Release ${tag}"
|
|
git push origin "${tag}"
|
|
|
|
echo ""
|
|
echo "Creating Gitea release..."
|
|
|
|
# Generate release notes from git log since last tag
|
|
prev_tag=$(git tag --sort=-v:refname | grep -v "^${tag}$" | head -1 || true)
|
|
if [ -n "$prev_tag" ]; then
|
|
release_notes=$(git log --pretty=format:"- %s" "${prev_tag}..${tag}")
|
|
else
|
|
release_notes=$(git log --pretty=format:"- %s" "${tag}")
|
|
fi
|
|
|
|
tea release create \
|
|
--tag "${tag}" \
|
|
--title "${tag}" \
|
|
--note "$release_notes" \
|
|
--asset ./arrman
|
|
|
|
echo ""
|
|
echo "Done! Published arrman ${tag}"
|
|
fi
|