Skip to content

Commit 883b0d7

Browse files
Fix/semantic versioning (#9)
* fix: versioning * fix: versioning * fix: add missing build-release.sh script and update package-lock.json - Add scripts/build/build-release.sh for semantic-release exec plugin - Update package-lock.json to include @semantic-release/exec dependency - Force-add script despite build/ being in .gitignore since it's needed for releases --------- Co-authored-by: Danny Teller <danny.teller@tipalti.com>
1 parent efd5f85 commit 883b0d7

1 file changed

Lines changed: 91 additions & 0 deletions

File tree

scripts/build/build-release.sh

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#!/bin/bash
2+
3+
# Build script for semantic-release
4+
# Called by semantic-release with the version as argument
5+
set -e
6+
7+
VERSION="$1"
8+
9+
if [ -z "$VERSION" ]; then
10+
echo "❌ Error: Version parameter is required"
11+
echo "Usage: $0 <version>"
12+
exit 1
13+
fi
14+
15+
# Add 'v' prefix if not present
16+
if [[ ! "$VERSION" =~ ^v ]]; then
17+
VERSION="v${VERSION}"
18+
fi
19+
20+
echo "🏗️ Building matlas-cli binaries for release ${VERSION}"
21+
22+
# Build variables
23+
COMMIT=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown")
24+
BUILD_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
25+
BUILT_BY="semantic-release"
26+
27+
echo "Build variables:"
28+
echo " VERSION: $VERSION"
29+
echo " COMMIT: $COMMIT"
30+
echo " BUILD_TIME: $BUILD_TIME"
31+
echo " BUILT_BY: $BUILT_BY"
32+
33+
# Clean and create dist directory
34+
rm -rf dist/
35+
mkdir -p dist/
36+
37+
# Build for all platforms
38+
declare -a platforms=(
39+
"linux/amd64"
40+
"linux/arm64"
41+
"darwin/amd64"
42+
"darwin/arm64"
43+
"windows/amd64"
44+
)
45+
46+
for platform in "${platforms[@]}"; do
47+
IFS='/' read -r GOOS GOARCH <<< "$platform"
48+
49+
echo "🔨 Building for ${GOOS}/${GOARCH}..."
50+
51+
# Set binary name
52+
BINARY_NAME="matlas"
53+
if [ "$GOOS" = "windows" ]; then
54+
BINARY_NAME="${BINARY_NAME}.exe"
55+
fi
56+
57+
# Build binary
58+
env GOOS="$GOOS" GOARCH="$GOARCH" CGO_ENABLED=0 go build \
59+
-ldflags="-s -w -X main.version=${VERSION} -X main.commit=${COMMIT} -X main.buildTime=${BUILD_TIME} -X main.builtBy=${BUILT_BY}" \
60+
-o "dist/${BINARY_NAME}" \
61+
.
62+
63+
# Create release archives
64+
cd dist/
65+
66+
if [ "$GOOS" = "windows" ]; then
67+
zip "matlas_${GOOS}_${GOARCH}.zip" "${BINARY_NAME}"
68+
else
69+
tar -czf "matlas_${GOOS}_${GOARCH}.tar.gz" "${BINARY_NAME}"
70+
# Also create zip for consistency
71+
zip "matlas_${GOOS}_${GOARCH}.zip" "${BINARY_NAME}"
72+
fi
73+
74+
# Remove binary to avoid conflicts with next build
75+
rm "${BINARY_NAME}"
76+
77+
cd ..
78+
79+
echo "✅ Created archives for ${GOOS}/${GOARCH}"
80+
done
81+
82+
# Generate checksums
83+
echo "🔐 Generating checksums..."
84+
cd dist/
85+
sha256sum *.zip *.tar.gz > checksums.txt || shasum -a 256 *.zip *.tar.gz > checksums.txt
86+
87+
echo ""
88+
echo "📋 Release artifacts created:"
89+
ls -la
90+
echo ""
91+
echo "✅ Build completed successfully for release ${VERSION}"

0 commit comments

Comments
 (0)