forked from aws/ec2-macos-init
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·31 lines (23 loc) · 781 Bytes
/
build.sh
File metadata and controls
executable file
·31 lines (23 loc) · 781 Bytes
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
#!/usr/bin/env bash
set -euo pipefail
log() { echo "> $*" >&2; }
if ! hash lipo 2>/dev/null; then
log "Unable to build universal binary without 'lipo' (macOS only)."
exit 1
fi
log "Building EC2 macOS Init..."
# Get commit date and version tag
COMMITDATE="$(git show -s --format=%ci HEAD)"
VERSION="$(git describe --always --tags)"
log "Commit date: ${COMMITDATE}"
log "Version: ${VERSION}"
for arch in amd64 arm64; do
log "Building for darwin/$arch"
GOOS=darwin GOARCH="$arch" CGO_ENABLED=0 \
go build -trimpath \
-ldflags="-s -w -X 'main.CommitDate=${COMMITDATE}' -X 'main.Version=${VERSION}'" \
-o "ec2-macos-init_$arch"
done
lipo -create -output ec2-macos-init \
ec2-macos-init_amd64 ec2-macos-init_arm64
log "Build complete"