-
Notifications
You must be signed in to change notification settings - Fork 159
Expand file tree
/
Copy pathrelease.sh
More file actions
executable file
·83 lines (68 loc) · 2.31 KB
/
release.sh
File metadata and controls
executable file
·83 lines (68 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
# DBDiff Local Release Helper
# Usage: ./release.sh [version]
# Example: ./release.sh v2.1.0
#
# This script builds the PHAR using box-project/box and tags the release.
# The actual platform binary builds and npm publishes are handled by the
# GitHub Actions workflow (.github/workflows/release.yml).
#
# Requirements:
# - PHP >= 8.0 in PATH
# - Composer dependencies installed (including box/box in dev)
set -e
VERSION=$1
if [ -z "$VERSION" ]; then
echo "Usage: $0 [version]"
echo "Example: $0 v2.1.0"
exit 1
fi
# Ensure we are in the project root
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR/.."
# Ensure we are on the main branch or current PR branch
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
echo "Preparing release $VERSION from branch $CURRENT_BRANCH..."
# 1. Check for uncommitted changes
if [ -n "$(git status --porcelain)" ]; then
echo "Error: You have uncommitted changes. Please commit or stash them first."
exit 1
fi
# 2. Update dependencies (production + dev for box)
echo "Updating dependencies..."
composer install --optimize-autoloader
# 3. Ensure box is available
if [ ! -f "vendor/bin/box" ]; then
echo "Error: vendor/bin/box not found."
echo "Install with: composer require --dev box/box"
exit 1
fi
# 4. Build the PHAR with Box
echo "Building PHAR with Box..."
mkdir -p dist
vendor/bin/box compile
# 5. Verify build artifacts
if [ ! -f "dist/dbdiff.phar" ]; then
echo "Error: dist/dbdiff.phar was not created."
exit 1
fi
PHAR_SIZE=$(du -sh dist/dbdiff.phar | cut -f1)
echo "PHAR built: dist/dbdiff.phar (${PHAR_SIZE})"
# 6. Quick smoke test — ensure the PHAR runs and reports the right version
echo "Smoke-testing PHAR..."
PHAR_VERSION=$(php dist/dbdiff.phar --version 2>&1 || true)
echo " ${PHAR_VERSION}"
# 7. Tag and Push
echo "Tagging version $VERSION..."
git tag -a "$VERSION" -m "Release $VERSION"
echo ""
echo "Done. To complete the release:"
echo " 1. git push origin $VERSION"
echo " 2. Trigger the GitHub Actions 'Release DBDiff' workflow with version: ${VERSION#v}"
echo " (This builds platform binaries, publishes to npm, and creates the GitHub Release)"
echo ""
echo "Or use the manual one-off binary builder:"
echo " scripts/release-binaries.sh ${VERSION#v}"
echo ""
echo "Artifacts:"
ls -lh dist/dbdiff.phar