Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support all valid architectures for target OSes #87

Merged
merged 3 commits into from
Jan 20, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions build-releases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if [ "$TRAVIS_PULL_REQUEST" != "false" ] || [ "$TRAVIS_BRANCH" != "master" ]; th
fi

# get hub if we don't have it
if ! command -v hub 2>&1 > /dev/null ; then
if ! command -v hub > /dev/null 2>&1 ; then
go get github.com/github/hub
fi

Expand All @@ -19,7 +19,7 @@ head_commit="$(git rev-parse HEAD 2> /dev/null)"
# build pre-release if not on a tag, otherwise build release
if ! git describe --tags --exact-match HEAD > /dev/null 2>&1 ; then
echo "Building pre-release, not tagged commit"
readonly tag="release-$(echo ${head_commit} | head -c 7)"
readonly tag="release-$(echo "$head_commit" | head -c 7)"
release_flags="--prerelease"
else
echo "Building release, tagged commit"
Expand All @@ -30,14 +30,22 @@ readonly project="muscadine"
readonly bin_name="$project"
readonly message="Automatic build"

declare -A arch_for_os
arch_for_os["darwin"]="amd64"
arch_for_os["windows"]="amd64"
arch_for_os["linux"]="amd64 arm64 ppc64 ppc64le mips64 mips64le s390x"
arch_for_os["openbsd"]="amd64"

# create the release and upload artifacts
hub release create $release_flags --message="$message" --commitish="$head_commit" "$tag"
for os in darwin linux windows openbsd; do
archive_name="$project-$os.tar.gz"
echo "Building $project for $os"
env GOOS="$os" CGO_ENABLED=0 go build -o "$bin_name" &&\
tar czf "$archive_name" "$bin_name" &&\
rm "$bin_name"
echo "Adding $archive_name to release $tag"
hub release edit --message="$message" --attach="$archive_name#muscadine_${os}" "$tag"
for arch in ${arch_for_os["$os"]}; do
archive_name="$project-$os-$arch.tar.gz"
echo "Building $project for $os on $arch"
env GOOS="$os" GOARCH="$arch" CGO_ENABLED=0 go build -o "$bin_name" &&\
tar czf "$archive_name" "$bin_name" &&\
rm "$bin_name"
echo "Adding $archive_name to release $tag"
hub release edit --message="$message" --attach="$archive_name#muscadine_${os}_${arch}" "$tag"
done
done