- Enhanced Makefile with cross-compilation for linux/amd64, linux/arm64, darwin/arm64, windows/amd64, windows/arm64 - Added GitHub Actions CI workflow for testing on all platforms - Added GitHub Actions Release workflow triggered by version tags - Added VERSION file for version tracking - Added scripts/release.sh for automated release process - Added Dockerfile for containerized builds - Added CONTRIBUTING.md with release process documentation - Added CHANGELOG.md for version tracking - Updated .gitignore to exclude build artifacts - Fixed unused variable in cmd/obm/main.go - Version now injected via ldflags (main.version, main.gitCommit, main.buildTime)
118 lines
No EOL
2.8 KiB
Bash
Executable file
118 lines
No EOL
2.8 KiB
Bash
Executable file
#!/bin/bash
|
|
# Release automation script for obm CLI
|
|
# Usage: ./scripts/release.sh <version>
|
|
# Example: ./scripts/release.sh v0.2.0
|
|
|
|
set -e
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
VERSION_FILE="$PROJECT_ROOT/VERSION"
|
|
|
|
# Colors
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
NC='\033[0m' # No Color
|
|
|
|
log_info() {
|
|
echo -e "${GREEN}[INFO]${NC} $1"
|
|
}
|
|
|
|
log_warn() {
|
|
echo -e "${YELLOW}[WARN]${NC} $1"
|
|
}
|
|
|
|
log_error() {
|
|
echo -e "${RED}[ERROR]${NC} $1"
|
|
}
|
|
|
|
# Validate version argument
|
|
if [ -z "$1" ]; then
|
|
log_error "Version argument required"
|
|
echo "Usage: $0 <version>"
|
|
echo "Example: $0 v0.2.0"
|
|
exit 1
|
|
fi
|
|
|
|
NEW_VERSION="$1"
|
|
|
|
# Strip 'v' prefix if present
|
|
VERSION_NUM="${NEW_VERSION#v}"
|
|
|
|
# Validate version format (semver)
|
|
if ! [[ "$VERSION_NUM" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$ ]]; then
|
|
log_error "Invalid version format: $NEW_VERSION"
|
|
echo "Expected format: vX.Y.Z or X.Y.Z (semver)"
|
|
exit 1
|
|
fi
|
|
|
|
cd "$PROJECT_ROOT"
|
|
|
|
# Check for uncommitted changes
|
|
if ! git diff-index --quiet HEAD --; then
|
|
log_error "Uncommitted changes detected. Please commit or stash first."
|
|
git status --short
|
|
exit 1
|
|
fi
|
|
|
|
# Check for unpushed commits
|
|
LOCAL=$(git rev-parse @)
|
|
REMOTE=$(git rev-parse @{u} 2>/dev/null || echo "")
|
|
|
|
if [ "$LOCAL" != "$REMOTE" ]; then
|
|
log_warn "Unpushed commits detected. Push before release?"
|
|
read -p "Push now? (y/N) " -n 1 -r
|
|
echo
|
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
git push
|
|
else
|
|
log_error "Please push changes before releasing"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
# Run tests
|
|
log_info "Running tests..."
|
|
make test || {
|
|
log_error "Tests failed. Fix before releasing."
|
|
exit 1
|
|
}
|
|
|
|
# Update VERSION file
|
|
log_info "Updating VERSION file to $VERSION_NUM"
|
|
echo "$VERSION_NUM" > "$VERSION_FILE"
|
|
|
|
# Update version in main.go
|
|
MAIN_GO="$PROJECT_ROOT/cmd/obm/main.go"
|
|
if [ -f "$MAIN_GO" ]; then
|
|
log_info "Updating version in main.go"
|
|
sed -i "s/^const version = \".*\"/const version = \"$VERSION_NUM\"/" "$MAIN_GO"
|
|
fi
|
|
|
|
# Commit version bump
|
|
log_info "Committing version bump"
|
|
git add "$VERSION_FILE" "$MAIN_GO"
|
|
git commit -m "chore: release v$VERSION_NUM"
|
|
|
|
# Create and push tag
|
|
TAG="v$VERSION_NUM"
|
|
log_info "Creating tag $TAG"
|
|
git tag -a "$TAG" -m "Release $TAG"
|
|
|
|
log_info "Pushing tag to remote..."
|
|
git push origin "$TAG"
|
|
|
|
log_info "Release process initiated!"
|
|
echo ""
|
|
echo "Version: $VERSION_NUM"
|
|
echo "Tag: $TAG"
|
|
echo ""
|
|
echo "Next steps:"
|
|
echo " 1. GitHub Actions will build and create the release automatically"
|
|
echo " 2. Monitor at: https://github.com/openboatmobile/obm/actions"
|
|
echo " 3. Draft release will be created at: https://github.com/openboatmobile/obm/releases"
|
|
echo ""
|
|
echo "To manually build binaries:"
|
|
echo " make cross-compile VERSION=$VERSION_NUM"
|
|
echo "" |