-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: build for multiple architectures on release (#54)
- Loading branch information
Showing
4 changed files
with
37 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
scripts/envbuilder | ||
scripts/envbuilder-* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,33 @@ | ||
#!/usr/bin/env bash | ||
|
||
cd $(dirname "${BASH_SOURCE[0]}") | ||
set -euxo pipefail | ||
set -euo pipefail | ||
|
||
CGO_ENABLED=0 go build -o ./envbuilder ../cmd/envbuilder | ||
docker build -t envbuilder:latest . | ||
archs=() | ||
for arg in "$@"; do | ||
if [[ $arg == --arch=* ]]; then | ||
arch="${arg#*=}" | ||
archs+=( "$arch" ) | ||
else | ||
echo "Unknown argument: $arg" | ||
exit 1 | ||
fi | ||
done | ||
|
||
current=$(go env GOARCH) | ||
if [ ${#archs[@]} -eq 0 ]; then | ||
echo "No architectures specified. Defaulting to $current..." | ||
archs=( "$current" ) | ||
fi | ||
|
||
for arch in "${archs[@]}"; do | ||
GOARCH=$arch CGO_ENABLED=0 go build -o ./envbuilder-$arch ../cmd/envbuilder && \ | ||
docker build --build-arg PLATFORM=$arch -t envbuilder:${arch} -f Dockerfile . & | ||
done | ||
wait | ||
|
||
# Check if archs contains the current. If so, then output a message! | ||
if [[ " ${archs[@]} " =~ " ${current} " ]]; then | ||
docker tag envbuilder:${arch} envbuilder:latest | ||
echo "Tagged $current as envbuilder:latest!" | ||
fi |