27 lines
783 B
Bash
Executable File
27 lines
783 B
Bash
Executable File
#!/bin/sh
|
|
# Build script for lab-ca with version injection from git tag
|
|
git describe --tags --always --dirty > /dev/null 2>&1
|
|
if [ $? -eq 0 ]; then
|
|
VERSION=$(git describe --tags --always --dirty)
|
|
else
|
|
VERSION="dev"
|
|
fi
|
|
|
|
# Hardcode the version into main.go
|
|
sed -i '' "s/^var Version = .*/var Version = \"$VERSION\"/" version.go
|
|
|
|
if echo $VERSION | grep -q 'dirty$'; then
|
|
echo "Building in development mode, output directory is set to 'build'."
|
|
OUTPUT_DIR=build
|
|
|
|
# Make sure the output directory exists, create it if it is not
|
|
mkdir -p $OUTPUT_DIR
|
|
else
|
|
echo "Building with version: $VERSION"
|
|
OUTPUT_DIR=$GOHOME/bin
|
|
fi
|
|
|
|
# Build the Lab CA binary with version information
|
|
# go build -ldflags "-X main.Version=$VERSION" -o $OUTPUT_DIR/lab-ca
|
|
go build -o $OUTPUT_DIR/lab-ca
|