|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +csource="${BASH_SOURCE[0]}" |
| 4 | +while [ -h "$csource" ] ; do csource="$(readlink "$csource")"; done |
| 5 | +root="$( cd -P "$( dirname "$csource" )/../" && pwd )" |
| 6 | + |
| 7 | +. "${root}/.ci/load-ci.sh" |
| 8 | + |
| 9 | +if [ "${#}" -ne 1 ]; then |
| 10 | + printf "Usage: %s ARTIFACTS_DIR\n" "${0}" >&2 |
| 11 | + exit 1 |
| 12 | +fi |
| 13 | + |
| 14 | +dest="${1}" |
| 15 | +mkdir -p "${dest}" || |
| 16 | + failure "Could not create destination directory (%s)" "${dest}" |
| 17 | +pushd "${dest}" |
| 18 | +dest="$(pwd)" || failure "Could not read destination directory path" |
| 19 | +popd |
| 20 | + |
| 21 | +# Move to root of project |
| 22 | +pushd "${root}" |
| 23 | + |
| 24 | +info "Building Vagrant RubyGem..." |
| 25 | +wrap gem build ./*.gemspec \ |
| 26 | + "Failed to build Vagrant RubyGem" |
| 27 | + |
| 28 | +# Get the path of the gem |
| 29 | +files=( vagrant*.gem ) |
| 30 | +gem="${files[0]}" |
| 31 | +if [ ! -f "${gem}" ]; then |
| 32 | + debug "could not locate gem in %s" "${files[*]}" |
| 33 | + failure "Unable to locate built Vagrant RubyGem" |
| 34 | +fi |
| 35 | + |
| 36 | +wrap mv "${gem}" "${dest}" \ |
| 37 | + "Failed to relocate Vagrant RubyGem" |
| 38 | + |
| 39 | +info "Installing submodules for vagrant-go build..." |
| 40 | +wrap git submodule update --init --recursive \ |
| 41 | + "Failed to install git submodules" |
| 42 | + |
| 43 | +# Build vagrant-go binaries |
| 44 | +info "Building vagrant-go linux amd64..." |
| 45 | +wrap make bin/linux \ |
| 46 | + "Failed to build the Vagrant go linux amd64 binary" |
| 47 | + |
| 48 | +# Rename our binary |
| 49 | +wrap mv vagrant "${dest}/vagrant-go_linux_amd64" \ |
| 50 | + "Failed to rename vagrant linux amd64 binary" |
| 51 | + |
| 52 | +info "Building vagrant-go linux 386..." |
| 53 | +# Build linux 386 binary |
| 54 | +wrap make bin/linux-386 \ |
| 55 | + "Failed to build the Vagrant go linux 386 binary" |
| 56 | + |
| 57 | +# Rename our binary |
| 58 | +wrap mv vagrant "${dest}/vagrant-go_linux_386" \ |
| 59 | + "Failed to rename vagrant linux 386 binary" |
| 60 | + |
| 61 | +info "Building vagrant-go darwin amd64..." |
| 62 | +# Build darwin binary |
| 63 | +wrap make bin/darwin \ |
| 64 | + "Failed to build the Vagrant go darwin amd64 binary" |
| 65 | + |
| 66 | +# Rename our binary |
| 67 | +wrap mv vagrant "${dest}/vagrant-go_darwin_amd64" \ |
| 68 | + "Failed to rename vagrant darwin amd64 binary" |
| 69 | + |
| 70 | +printf "build-artifacts-path=%s\n" "${dest}" |
0 commit comments