From 67b6758bed85fc9e092f88bcc8a72ebd04ee32b5 Mon Sep 17 00:00:00 2001 From: Mahmood Ali Date: Thu, 14 Mar 2019 07:45:49 -0400 Subject: [PATCH 01/10] Add a Docker release scripts Also tease out some dev and docker bits from Vagrant scripts to ease sharing with Docker script --- Vagrantfile | 8 +++++ scripts/release/Dockerfile | 44 ++++++++++++++++++++++++++++ scripts/release/Makefile.linux | 29 ++++++++++++++++++ scripts/release/docker-build-all | 20 +++++++++++++ scripts/vagrant-linux-priv-config.sh | 16 ---------- scripts/vagrant-linux-priv-dev.sh | 24 +++++++++++++++ scripts/vagrant-linux-priv-docker.sh | 21 +++++++++++++ 7 files changed, 146 insertions(+), 16 deletions(-) create mode 100644 scripts/release/Dockerfile create mode 100644 scripts/release/Makefile.linux create mode 100755 scripts/release/docker-build-all create mode 100755 scripts/vagrant-linux-priv-dev.sh create mode 100755 scripts/vagrant-linux-priv-docker.sh diff --git a/Vagrantfile b/Vagrantfile index 7a182f8f6..7fab7e224 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -125,6 +125,14 @@ def configureLinuxProvisioners(vmCfg) privileged: true, path: './scripts/vagrant-linux-priv-config.sh' + vmCfg.vm.provision "shell", + privileged: true, + path: './scripts/vagrant-linux-priv-dev.sh' + + vmCfg.vm.provision "shell", + privileged: true, + path: './scripts/vagrant-linux-priv-docker.sh' + vmCfg.vm.provision "shell", privileged: true, path: './scripts/vagrant-linux-priv-consul.sh' diff --git a/scripts/release/Dockerfile b/scripts/release/Dockerfile new file mode 100644 index 000000000..035004e73 --- /dev/null +++ b/scripts/release/Dockerfile @@ -0,0 +1,44 @@ +# Dockerfile for building nomad binaries +# that mimics Vagrant environment as far as required +# for building the scripts and running provision scripts + +FROM ubuntu:16.04 + +RUN apt-get update; apt-get install -y \ + apt-transport-https \ + ca-certificates \ + curl \ + git \ + sudo \ + tree \ + unzip \ + wget + +RUN useradd --create-home vagrant \ + && echo 'vagrant ALL = (ALL) NOPASSWD: ALL' >> /etc/sudoers + +# install priv packages +ADD ./scripts/vagrant-linux-priv-config.sh /tmp/scripts/vagrant-linux-priv-config.sh +RUN /tmp/scripts/vagrant-linux-priv-config.sh + +ADD ./scripts/vagrant-linux-priv-go.sh /tmp/scripts/vagrant-linux-priv-go.sh +RUN /tmp/scripts/vagrant-linux-priv-go.sh + +ADD ./scripts/vagrant-linux-priv-protoc.sh /tmp/scripts/vagrant-linux-priv-protoc.sh +RUN /tmp/scripts/vagrant-linux-priv-protoc.sh + +USER vagrant + +ADD ./scripts/vagrant-linux-unpriv-ui.sh /tmp/scripts/vagrant-linux-unpriv-ui.sh +RUN /tmp/scripts/vagrant-linux-unpriv-ui.sh + +# Update PATH with GO bin, yarn, and node +ENV GOPATH="/opt/gopath" \ + PATH="/home/vagrant/bin:/opt/gopath/bin:/home/vagrant/.yarn/bin:/home/vagrant/.config/yarn/global/node_modules/.bin:$PATH" + +RUN mkdir -p /opt/gopath/src/github.com/hashicorp/nomad +RUN mkdir -p /home/vagrant/bin \ + && git config --global user.email "nomad@hashicorp.com" \ + && git config --global user.name "Nomad Release Bot" + +COPY --chown=vagrant:vagrant ./scripts/release/docker-build-all /home/vagrant/bin/docker-build-all diff --git a/scripts/release/Makefile.linux b/scripts/release/Makefile.linux new file mode 100644 index 000000000..70f7bd65e --- /dev/null +++ b/scripts/release/Makefile.linux @@ -0,0 +1,29 @@ + +NOMAD_VERSION = 0.9.0-dev + +NOMAD_MAIN_VERSION := $(shell echo $(NOMAD_VERSION) | cut -d- -f1) +NOMAD_PRERELEASE_VERSION := $(shell echo $(NOMAD_VERSION) | cut -d- -f2-) + +update_version: + @echo "updating version to $(NOMAD_MAIN_VERSION)-$(NOMAD_PRERELEASE_VERSION)" + @sed -i.bak -e 's|\(Version * = *"\)[^"]*|\1$(NOMAD_MAIN_VERSION)|g' version/version.go + @sed -i.bak -e 's|\(VersionPrerelease * = *"\)[^"]*|\1$(NOMAD_PRERELEASE_VERSION)|g' version/version.go + @rm -rf version/version.go.bak + +PRERELEASE_TARGET = prerelease +RELEASE_TARGET = release + +build_releases: + @echo "======>> installing dependencies" + $(MAKE) bootstrap + + @echo "======>> pre-releasing" + $(MAKE) $(PRERELEASE_TARGET) + + @echo "======>> committing generated files" + git add -A . + git commit --author 'Nomad Release bot ' \ + --message "Generate files for $(NOMAD_VERSION) release" + + @echo "======>> building release artifacts" + $(MAKE) $(RELEASE_TARGET) diff --git a/scripts/release/docker-build-all b/scripts/release/docker-build-all new file mode 100755 index 000000000..f1be5aca5 --- /dev/null +++ b/scripts/release/docker-build-all @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +. ~/.nvm/nvm.sh + +set -e +set -x + +cp -r /tmp/nomad-git /opt/gopath/src/github.com/hashicorp/nomad/.git + +cd /opt/gopath/src/github.com/hashicorp/nomad +git checkout . + +make -f ./scripts/release/Makefile.linux \ + "NOMAD_VERSION=${NOMAD_VERSION}" \ + "PRERELEASE_TARGET=${PRERELEASE_TARGET}" \ + "RELEASE_TARGET=${RELEASE_TARGET}" \ + update_version build_releases + +cp -r /opt/gopath/src/github.com/hashicorp/nomad \ + /tmp/artifacts/repo diff --git a/scripts/vagrant-linux-priv-config.sh b/scripts/vagrant-linux-priv-config.sh index 7c8b38c52..b2400c5c0 100755 --- a/scripts/vagrant-linux-priv-config.sh +++ b/scripts/vagrant-linux-priv-config.sh @@ -9,15 +9,6 @@ apt-get install -y software-properties-common # Add i386 architecture (for libraries) dpkg --add-architecture i386 -# Add the Docker repository -apt-key adv \ - --keyserver hkp://p80.pool.sks-keyservers.net:80 \ - --recv-keys 9DC858229FC7DD38854AE2D88D81803C0EBFCD88 -add-apt-repository \ - "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ - $(lsb_release -cs) \ - stable" - # Update with i386, Go and Docker apt-get update @@ -35,7 +26,6 @@ apt-get install -y \ apt-get install -y \ curl \ default-jre \ - docker-ce \ htop \ jq \ qemu \ @@ -60,12 +50,6 @@ apt-get install -y \ # Ensure everything is up to date apt-get upgrade -y -# Restart Docker in case it got upgraded -systemctl restart docker.service - -# Ensure Docker can be used by vagrant user -usermod -aG docker vagrant - # Set hostname -> IP to make advertisement work as expected ip=$(ip route get 1 | awk '{print $NF; exit}') hostname=$(hostname) diff --git a/scripts/vagrant-linux-priv-dev.sh b/scripts/vagrant-linux-priv-dev.sh new file mode 100755 index 000000000..2b22a36a6 --- /dev/null +++ b/scripts/vagrant-linux-priv-dev.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +# Install Development utilities +apt-get install -y \ + curl \ + default-jre \ + htop \ + jq \ + qemu \ + silversearcher-ag \ + tree \ + unzip \ + vim + + +# Set hostname -> IP to make advertisement work as expected +ip=$(ip route get 1 | awk '{print $NF; exit}') +hostname=$(hostname) +sed -i -e "s/.*nomad.*/${ip} ${hostname}/" /etc/hosts + +# Ensure we cd into the working directory on login +if ! grep "cd /opt/gopath/src/github.com/hashicorp/nomad" /home/vagrant/.profile ; then + echo 'cd /opt/gopath/src/github.com/hashicorp/nomad' >> /home/vagrant/.profile +fi diff --git a/scripts/vagrant-linux-priv-docker.sh b/scripts/vagrant-linux-priv-docker.sh new file mode 100755 index 000000000..22a9c5717 --- /dev/null +++ b/scripts/vagrant-linux-priv-docker.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +# Add the Docker repository +apt-key adv \ + --keyserver hkp://p80.pool.sks-keyservers.net:80 \ + --recv-keys 9DC858229FC7DD38854AE2D88D81803C0EBFCD88 +add-apt-repository \ + "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ + $(lsb_release -cs) \ + stable" + +# Update with i386, Go and Docker +apt-get update + +apt-get install -y docker-ce + +# Restart Docker in case it got upgraded +systemctl restart docker.service + +# Ensure Docker can be used by vagrant user +usermod -aG docker vagrant From 67bb6c839c6822d5c2226645a288dafb3f4d7983 Mon Sep 17 00:00:00 2001 From: Mahmood Ali Date: Fri, 15 Mar 2019 11:02:52 -0400 Subject: [PATCH 02/10] remove chown --- scripts/release/Dockerfile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/release/Dockerfile b/scripts/release/Dockerfile index 035004e73..e728b1ae0 100644 --- a/scripts/release/Dockerfile +++ b/scripts/release/Dockerfile @@ -18,20 +18,22 @@ RUN useradd --create-home vagrant \ && echo 'vagrant ALL = (ALL) NOPASSWD: ALL' >> /etc/sudoers # install priv packages -ADD ./scripts/vagrant-linux-priv-config.sh /tmp/scripts/vagrant-linux-priv-config.sh +COPY ./scripts/vagrant-linux-priv-config.sh /tmp/scripts/vagrant-linux-priv-config.sh RUN /tmp/scripts/vagrant-linux-priv-config.sh -ADD ./scripts/vagrant-linux-priv-go.sh /tmp/scripts/vagrant-linux-priv-go.sh +COPY ./scripts/vagrant-linux-priv-go.sh /tmp/scripts/vagrant-linux-priv-go.sh RUN /tmp/scripts/vagrant-linux-priv-go.sh -ADD ./scripts/vagrant-linux-priv-protoc.sh /tmp/scripts/vagrant-linux-priv-protoc.sh +COPY ./scripts/vagrant-linux-priv-protoc.sh /tmp/scripts/vagrant-linux-priv-protoc.sh RUN /tmp/scripts/vagrant-linux-priv-protoc.sh USER vagrant -ADD ./scripts/vagrant-linux-unpriv-ui.sh /tmp/scripts/vagrant-linux-unpriv-ui.sh +COPY ./scripts/vagrant-linux-unpriv-ui.sh /tmp/scripts/vagrant-linux-unpriv-ui.sh RUN /tmp/scripts/vagrant-linux-unpriv-ui.sh +COPY ./scripts/release/docker-build-all /tmp/scripts/docker-build-all + # Update PATH with GO bin, yarn, and node ENV GOPATH="/opt/gopath" \ PATH="/home/vagrant/bin:/opt/gopath/bin:/home/vagrant/.yarn/bin:/home/vagrant/.config/yarn/global/node_modules/.bin:$PATH" @@ -40,5 +42,3 @@ RUN mkdir -p /opt/gopath/src/github.com/hashicorp/nomad RUN mkdir -p /home/vagrant/bin \ && git config --global user.email "nomad@hashicorp.com" \ && git config --global user.name "Nomad Release Bot" - -COPY --chown=vagrant:vagrant ./scripts/release/docker-build-all /home/vagrant/bin/docker-build-all From 4db32eb0841c15556a8f46bc2e0cd759b914a48f Mon Sep 17 00:00:00 2001 From: Mahmood Ali Date: Fri, 15 Mar 2019 09:55:13 -0400 Subject: [PATCH 03/10] initial attempt at building mac --- scripts/release/mac-remote-build | 72 ++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100755 scripts/release/mac-remote-build diff --git a/scripts/release/mac-remote-build b/scripts/release/mac-remote-build new file mode 100755 index 000000000..c70135ee8 --- /dev/null +++ b/scripts/release/mac-remote-build @@ -0,0 +1,72 @@ +#!/usr/bin/env bash + +set -e + +REPO="$1" +RELEASE_TARGET="${2:-release}" + +if [[ -z "${REPO}" ]] +then + echo "repo path is required" + exit 1 +fi + +TMP_WORKSPACE="/tmp/nomad-workspace/$(date +%Y-%m-%d-%s)" +REPO_REMOTE_PATH="${TMP_WORKSPACE}/gopath/src/github.com/hashicorp/nomad" + +echo "Using temp workspace: ${TMP_WORKSPACE}" +echo + +echo '=======>>>> Transfering repository' +ssh sharedmac-bot mkdir -p "${REPO_REMOTE_PATH}" +rsync -az \ + "${REPO}/.git" \ + "sharedmac-bot:${REPO_REMOTE_PATH}" + +echo '=======>>>> Compiling Mac Binaries' +cat <<'EOF' | ssh sharedmac-bot /bin/bash -s "${TMP_WORKSPACE}" + +set -ex + +TMP_WORKSPACE="$1" +REPO_PATH="${TMP_WORKSPACE}/gopath/src/github.com/hashicorp/nomad" + + +mkdir -p "${TMP_WORKSPACE}/tmp" + +install_go() { + local go_version="1.11.5" + local download= + + download="https://storage.googleapis.com/golang/go${go_version}.darwin-amd64.tar.gz" + curl -sSL --fail -o "${TMP_WORKSPACE}/tmp/go.tar.gz" ${download} + + tar -C "${TMP_WORKSPACE}" -xf "${TMP_WORKSPACE}/tmp/go.tar.gz" +} + +install_release_deps() { + go get -u github.com/a8m/tree/cmd/tree +} + +compile() { + cd "${REPO_PATH}" + git checkout . + git status + git log -1 + make release +} + +install_go + +export GOPATH="${TMP_WORKSPACE}/gopath" +export PATH="${TMP_WORKSPACE}/go/bin:${GOPATH}/bin:$PATH" + +install_release_deps +compile + +EOF + +echo '=======>>>> Retreiving mac compiled binaries' +rsync -avz --ignore-existing sharedmac-bot:"${REPO_REMOTE_PATH}/pkg/" "${REPO}/pkg" + +ssh sharedmac-bot rm -rf "${TMP_WORKSPACE}" From 49f807f72c1961cb26c62373460cecf1d3e48741 Mon Sep 17 00:00:00 2001 From: Mahmood Ali Date: Sat, 16 Mar 2019 10:39:24 -0400 Subject: [PATCH 04/10] handle when no files are generated --- scripts/release/Makefile.linux | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/release/Makefile.linux b/scripts/release/Makefile.linux index 70f7bd65e..1e0df8a10 100644 --- a/scripts/release/Makefile.linux +++ b/scripts/release/Makefile.linux @@ -22,8 +22,11 @@ build_releases: @echo "======>> committing generated files" git add -A . - git commit --author 'Nomad Release bot ' \ - --message "Generate files for $(NOMAD_VERSION) release" + if ! git diff-index --quiet HEAD --; \ + then \ + git commit --author 'Nomad Release bot ' \ + --message "Generate files for $(NOMAD_VERSION) release"; \ + fi @echo "======>> building release artifacts" $(MAKE) $(RELEASE_TARGET) From 4832c773639800e0832f357cb301f695e4933371 Mon Sep 17 00:00:00 2001 From: Mahmood Ali Date: Mon, 18 Mar 2019 08:45:25 -0400 Subject: [PATCH 05/10] scripts: only shellcheck shell scripts --- GNUmakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GNUmakefile b/GNUmakefile index 26b3b64df..bb26911f8 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -186,7 +186,7 @@ check: ## Lint the source code .PHONY: checkscripts checkscripts: ## Lint shell scripts @echo "==> Linting scripts..." - @shellcheck ./scripts/* + @find scripts -type f -name '*.sh' | xargs shellcheck .PHONY: generate-all generate-all: generate-structs proto From 1bc81dc6e3e62b084ffb638e0f09175d7de0728d Mon Sep 17 00:00:00 2001 From: Mahmood Ali Date: Mon, 18 Mar 2019 14:31:31 -0400 Subject: [PATCH 06/10] ensure node is present in PATH --- scripts/release/Dockerfile | 3 ++- scripts/release/docker-build-all | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/release/Dockerfile b/scripts/release/Dockerfile index e728b1ae0..2957dc00f 100644 --- a/scripts/release/Dockerfile +++ b/scripts/release/Dockerfile @@ -35,8 +35,9 @@ RUN /tmp/scripts/vagrant-linux-unpriv-ui.sh COPY ./scripts/release/docker-build-all /tmp/scripts/docker-build-all # Update PATH with GO bin, yarn, and node +ENV NODE_VERSION=v8.11.2 ENV GOPATH="/opt/gopath" \ - PATH="/home/vagrant/bin:/opt/gopath/bin:/home/vagrant/.yarn/bin:/home/vagrant/.config/yarn/global/node_modules/.bin:$PATH" + PATH="/home/vagrant/.nvm/versions/node/${NODE_VERSION}/bin:/home/vagrant/bin:/opt/gopath/bin:/home/vagrant/.yarn/bin:/home/vagrant/.config/yarn/global/node_modules/.bin:$PATH" RUN mkdir -p /opt/gopath/src/github.com/hashicorp/nomad RUN mkdir -p /home/vagrant/bin \ diff --git a/scripts/release/docker-build-all b/scripts/release/docker-build-all index f1be5aca5..32c45034b 100755 --- a/scripts/release/docker-build-all +++ b/scripts/release/docker-build-all @@ -1,7 +1,5 @@ #!/usr/bin/env bash -. ~/.nvm/nvm.sh - set -e set -x From 77cd7f8e13ebe9cfaf30fa955ca105e35fa7f08f Mon Sep 17 00:00:00 2001 From: Mahmood Ali Date: Mon, 18 Mar 2019 14:34:09 -0400 Subject: [PATCH 07/10] use bash set long form --- scripts/release/docker-build-all | 4 ++-- scripts/release/mac-remote-build | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/release/docker-build-all b/scripts/release/docker-build-all index 32c45034b..268515dcb 100755 --- a/scripts/release/docker-build-all +++ b/scripts/release/docker-build-all @@ -1,7 +1,7 @@ #!/usr/bin/env bash -set -e -set -x +set -o errexit +set -o xtrace cp -r /tmp/nomad-git /opt/gopath/src/github.com/hashicorp/nomad/.git diff --git a/scripts/release/mac-remote-build b/scripts/release/mac-remote-build index c70135ee8..8ee6b6946 100755 --- a/scripts/release/mac-remote-build +++ b/scripts/release/mac-remote-build @@ -1,6 +1,6 @@ #!/usr/bin/env bash -set -e +set -o errexit REPO="$1" RELEASE_TARGET="${2:-release}" @@ -26,7 +26,8 @@ rsync -az \ echo '=======>>>> Compiling Mac Binaries' cat <<'EOF' | ssh sharedmac-bot /bin/bash -s "${TMP_WORKSPACE}" -set -ex +set -o errexit +set -o xtrace TMP_WORKSPACE="$1" REPO_PATH="${TMP_WORKSPACE}/gopath/src/github.com/hashicorp/nomad" From 88288a1819632e7ef76c1dcb1f68ca82f4ede7c8 Mon Sep 17 00:00:00 2001 From: Mahmood Ali Date: Mon, 18 Mar 2019 15:05:32 -0400 Subject: [PATCH 08/10] accept macos host as a env-var with a default --- scripts/release/mac-remote-build | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/release/mac-remote-build b/scripts/release/mac-remote-build index 8ee6b6946..bf386aa18 100755 --- a/scripts/release/mac-remote-build +++ b/scripts/release/mac-remote-build @@ -14,17 +14,19 @@ fi TMP_WORKSPACE="/tmp/nomad-workspace/$(date +%Y-%m-%d-%s)" REPO_REMOTE_PATH="${TMP_WORKSPACE}/gopath/src/github.com/hashicorp/nomad" +readonly remote_macos_host=${REMOTE_MACOS_HOST:-sharedmac-bot} + echo "Using temp workspace: ${TMP_WORKSPACE}" echo echo '=======>>>> Transfering repository' -ssh sharedmac-bot mkdir -p "${REPO_REMOTE_PATH}" +ssh ${remote_macos_host} mkdir -p "${REPO_REMOTE_PATH}" rsync -az \ "${REPO}/.git" \ - "sharedmac-bot:${REPO_REMOTE_PATH}" + "${remote_macos_host}:${REPO_REMOTE_PATH}" echo '=======>>>> Compiling Mac Binaries' -cat <<'EOF' | ssh sharedmac-bot /bin/bash -s "${TMP_WORKSPACE}" +cat <<'EOF' | ssh ${remote_macos_host} /bin/bash -s "${TMP_WORKSPACE}" set -o errexit set -o xtrace @@ -68,6 +70,6 @@ compile EOF echo '=======>>>> Retreiving mac compiled binaries' -rsync -avz --ignore-existing sharedmac-bot:"${REPO_REMOTE_PATH}/pkg/" "${REPO}/pkg" +rsync -avz --ignore-existing ${remote_macos_host}:"${REPO_REMOTE_PATH}/pkg/" "${REPO}/pkg" -ssh sharedmac-bot rm -rf "${TMP_WORKSPACE}" +ssh ${remote_macos_host} rm -rf "${TMP_WORKSPACE}" From 7f911555b5f503a196e0dd7c6a14f051a041881d Mon Sep 17 00:00:00 2001 From: Mahmood Ali Date: Tue, 19 Mar 2019 21:18:27 -0400 Subject: [PATCH 09/10] Add some release script comments --- scripts/release/Makefile.linux | 2 ++ scripts/release/docker-build-all | 28 ++++++++++++++++++++++++++++ scripts/release/mac-remote-build | 17 +++++++++++++++++ 3 files changed, 47 insertions(+) diff --git a/scripts/release/Makefile.linux b/scripts/release/Makefile.linux index 1e0df8a10..053232f59 100644 --- a/scripts/release/Makefile.linux +++ b/scripts/release/Makefile.linux @@ -22,6 +22,8 @@ build_releases: @echo "======>> committing generated files" git add -A . +# skip comitting files if there are no generated files +# if prerelease process was a no-op if ! git diff-index --quiet HEAD --; \ then \ git commit --author 'Nomad Release bot ' \ diff --git a/scripts/release/docker-build-all b/scripts/release/docker-build-all index 268515dcb..a219260d3 100755 --- a/scripts/release/docker-build-all +++ b/scripts/release/docker-build-all @@ -1,11 +1,39 @@ #!/usr/bin/env bash +# A script for building Linux and Windows nomad release binaries inside Docker +# +# This is a helper script file that is expected to be invoked +# within a docker container with an image created with the Dockerfile present on this directory. +# +# A sample way of invoking the script is +# ``` +# docker run --rm \ +# -v $(pwd)/.git:/tmp/nomad-git:ro \ +# -v /tmp/generated-repo:/tmp/artifacts:rw \ +# -e "PRERELEASE_TARGET=${PRERELEASE_TARGET}" \ +# -e "RELEASE_TARGET=${RELEASE_TARGET}" \ +# -e "NOMAD_VERSION=${NOMAD_VERSION}" \ +# nomad-builder:latest \ +# /tmp/scripts/docker-build-all +# ``` +# Namely the script takes the following arguments: +# * `/tmp/nomad-git` path being a read-only .git directory with HEAD being the sha to be released +# * `NOMAD_VERSION` env-var being the release version to be cut (e.g. `0.9.1-rc1`) +# * `PRERELEASE_TARGET` env-var being the prerelease make target, typically `prerelease`. Use `help` to skip `prerelease` step +# * `RELEASE_TARGET` env-var being the release make target, typically `release`. +# +# +# The script would then run prerelease steps, commits any generated files, and build all binary files +# and stores them to `/tmp/artifacts/repo`. + set -o errexit set -o xtrace cp -r /tmp/nomad-git /opt/gopath/src/github.com/hashicorp/nomad/.git cd /opt/gopath/src/github.com/hashicorp/nomad + +# checkout directory from .git and ensures a prestine state git checkout . make -f ./scripts/release/Makefile.linux \ diff --git a/scripts/release/mac-remote-build b/scripts/release/mac-remote-build index bf386aa18..e50ced02c 100755 --- a/scripts/release/mac-remote-build +++ b/scripts/release/mac-remote-build @@ -1,5 +1,21 @@ #!/usr/bin/env bash +# A script for building macOS binary on a remote macOS host +# +# The helper is expected to be invoked with nomad repo as a first argument, e.g. +# `mac-remote-build ~/go/src/github.com/hashicorp/nomad`. +# +# The repository is required to have a HEAD with all generated files and udpated version committed. +# +# The script runs a host on `sharedmac-bot` host (assumes a corresponding entry in ~/.ssh/config). +# `REMOTE_MACOS_HOST` envvar can be set to point to another macOS host +# +# The script operates by creating a temporary workspace in the remote host to +# contain a clean go installation and gopath with the repository content. +# It should install all dependencies worth pinning, and *not* use system binaries +# that may influence the integrity of the release. +# + set -o errexit REPO="$1" @@ -8,6 +24,7 @@ RELEASE_TARGET="${2:-release}" if [[ -z "${REPO}" ]] then echo "repo path is required" + echo "Usage: $0 " exit 1 fi From 4a9f29c1a6c487561e64124ade8ec960baab2aab Mon Sep 17 00:00:00 2001 From: Mahmood Ali Date: Tue, 19 Mar 2019 21:18:44 -0400 Subject: [PATCH 10/10] release: Upgrade to use 1.11.6 golang on macOS To correspond to the Linux scripts in 855761a5dff9b447152e8ea75a410aafa46e66dc --- scripts/release/mac-remote-build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/release/mac-remote-build b/scripts/release/mac-remote-build index e50ced02c..0c0b2387c 100755 --- a/scripts/release/mac-remote-build +++ b/scripts/release/mac-remote-build @@ -55,7 +55,7 @@ REPO_PATH="${TMP_WORKSPACE}/gopath/src/github.com/hashicorp/nomad" mkdir -p "${TMP_WORKSPACE}/tmp" install_go() { - local go_version="1.11.5" + local go_version="1.11.6" local download= download="https://storage.googleapis.com/golang/go${go_version}.darwin-amd64.tar.gz"