github.com/nikron/prototool@v1.3.0/etc/bin/releasegen.sh (about)

     1  #!/bin/bash
     2  
     3  set -euo pipefail
     4  
     5  DIR="$(cd "$(dirname "${0}")/../.." && pwd)"
     6  cd "${DIR}"
     7  
     8  goos() {
     9    case "${1}" in
    10      Darwin) echo darwin ;;
    11      Linux) echo linux ;;
    12      *) return 1 ;;
    13    esac
    14  }
    15  
    16  goarch() {
    17    case "${1}" in
    18      x86_64) echo amd64 ;;
    19      *) return 1 ;;
    20    esac
    21  }
    22  
    23  BASE_DIR="release"
    24  
    25  go get github.com/Masterminds/glide
    26  rm -rf vendor
    27  glide install
    28  rm -rf "${BASE_DIR}"
    29  for os in Darwin Linux; do
    30    for arch in x86_64; do
    31      dir="${BASE_DIR}/${os}/${arch}/prototool"
    32      tar_context_dir="$(dirname "${dir}")"
    33      tar_dir="prototool"
    34      mkdir -p "${dir}/bin"
    35      mkdir -p "${dir}/etc/bash_completion.d"
    36      mkdir -p "${dir}/etc/zsh/site-functions"
    37      mkdir -p "${dir}/share/man/man1"
    38      go run internal/cmd/gen-prototool-bash-completion/main.go > "${dir}/etc/bash_completion.d/prototool"
    39      go run internal/cmd/gen-prototool-zsh-completion/main.go > "${dir}/etc/zsh/site-functions/_prototool"
    40      go run internal/cmd/gen-prototool-manpages/main.go "${dir}/share/man/man1"
    41      CGO_ENABLED=0 GOOS=$(goos "${os}") GOARCH=$(goarch "${arch}") \
    42        go build \
    43        -a \
    44        -installsuffix cgo \
    45        -ldflags "-X 'github.com/uber/prototool/internal/vars.GitCommit=$(git rev-list -1 HEAD)' -X 'github.com/uber/prototool/internal/vars.BuiltTimestamp=$(date -u)'" \
    46        -o "${dir}/bin/prototool" \
    47        internal/cmd/prototool/main.go
    48      tar -C "${tar_context_dir}" -cvzf "${BASE_DIR}/prototool-${os}-${arch}.tar.gz" "${tar_dir}"
    49      cp "${dir}/bin/prototool" "${BASE_DIR}/prototool-${os}-${arch}"
    50    done
    51    rm -rf "${BASE_DIR:?/tmp}/${os}"
    52  done