Two scripts: - prepare-release.sh (run by me/Kiro on dev machine): Writes releases/vX.Y.Z.md, bumps packageVersion, commits, tags, pushes - release.sh (run by you on Mac): Reads version from current git tag, reads notes from releases/<tag>.md, builds DMG, creates Gitea release, uploads DMG. No user input needed — just run ./release.sh Workflow: Dev: ./prepare-release.sh 1.0.0 'Release notes' Mac: git fetch --tags && git checkout v1.0.0 && ./release.sh
69 lines
2.9 KiB
Bash
Executable File
69 lines
2.9 KiB
Bash
Executable File
#!/bin/bash
|
|
# prepare-release.sh — prepare a release commit and tag (run on dev machine)
|
|
#
|
|
# Usage:
|
|
# ./prepare-release.sh 1.0.0 "Release notes here..."
|
|
#
|
|
# This script:
|
|
# 1. Writes release notes to releases/v<version>.md
|
|
# 2. Updates packageVersion in build.gradle.kts
|
|
# 3. Commits both
|
|
# 4. Creates and pushes the annotated tag
|
|
#
|
|
# After this, the Mac operator runs ./release.sh to build and upload.
|
|
|
|
set -euo pipefail
|
|
|
|
if [ $# -lt 2 ]; then
|
|
echo "Usage: $0 <version> <release-notes>"
|
|
echo " Example: $0 1.0.0 'First release with Android and iPhone support'"
|
|
exit 1
|
|
fi
|
|
|
|
VERSION="$1"
|
|
TAG="v${VERSION}"
|
|
NOTES="$2"
|
|
|
|
# ── Pre-flight ────────────────────────────────────────────────────────────────
|
|
if ! git diff --quiet || ! git diff --cached --quiet; then
|
|
echo "ERROR: Uncommitted changes. Commit or stash first."
|
|
exit 1
|
|
fi
|
|
|
|
if git tag | grep -q "^${TAG}$"; then
|
|
echo "ERROR: Tag $TAG already exists."
|
|
exit 1
|
|
fi
|
|
|
|
# ── Write release notes ───────────────────────────────────────────────────────
|
|
mkdir -p releases
|
|
NOTES_FILE="releases/${TAG}.md"
|
|
cat > "$NOTES_FILE" << EOF
|
|
$NOTES
|
|
EOF
|
|
echo "→ Wrote $NOTES_FILE"
|
|
|
|
# ── Update version ────────────────────────────────────────────────────────────
|
|
sed -i "s/packageVersion = \"[^\"]*\"/packageVersion = \"${VERSION}\"/" build.gradle.kts
|
|
echo "→ Updated packageVersion to $VERSION"
|
|
|
|
# ── Commit ────────────────────────────────────────────────────────────────────
|
|
git add "$NOTES_FILE" build.gradle.kts
|
|
git commit -m "Release $TAG"
|
|
echo "→ Committed release files"
|
|
|
|
# ── Tag ───────────────────────────────────────────────────────────────────────
|
|
git tag -a "$TAG" -m "$NOTES"
|
|
echo "→ Created tag $TAG"
|
|
|
|
# ── Push ──────────────────────────────────────────────────────────────────────
|
|
echo "→ Pushing to origin..."
|
|
GIT_ASKPASS='' GIT_TERMINAL_PROMPT=0 git push origin HEAD:refs/heads/main 2>&1 || \
|
|
echo " (push to main may require running from Mac — tag is local)"
|
|
GIT_ASKPASS='' GIT_TERMINAL_PROMPT=0 git push origin "$TAG" 2>&1 || \
|
|
echo " (tag push may require running from Mac)"
|
|
|
|
echo ""
|
|
echo "✓ Release $TAG prepared."
|
|
echo " On your Mac: git fetch --tags && git checkout $TAG && ./release.sh"
|