Skip to content

Commit

Permalink
Adding scripts to be able to do local releases (istio#14562)
Browse files Browse the repository at this point in the history
* Fixing Quotes

* adding local build

* few fixes

* fix

* shellcheck

* remove fake

* added readme

* Update change to include getting long api sha

* fix lint
  • Loading branch information
utka authored and istio-testing committed Jun 18, 2019
1 parent a8a573b commit d8b9a10
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 45 deletions.
11 changes: 11 additions & 0 deletions release/gcb/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
To create local release run local.sh
You should provide docker hub where local images can be pushed and version of the release.
It is going to perform next steps.

1. Create manifest file with all repos SHAs. Make sure that repos on your local machine synced to correct SHA.
// Work in Progress
2. Creates Istio images with new version tag
3. Updates charts with provided version.



39 changes: 39 additions & 0 deletions release/gcb/gcb_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,42 @@ function github_keys() {
gsutil -q cp "gs://${CB_TEST_GITHUB_TOKEN_FILE_PATH}" "${KEYFILE_TEMP}"
fi
}

function create_manifest_check_consistency() {
local MANIFEST_FILE=$1

local ISTIO_REPO_SHA
local PROXY_REPO_SHA
local CNI_REPO_SHA
local API_REPO_SHA
ISTIO_REPO_SHA=$(git rev-parse HEAD)
CNI_REPO_SHA=$(grep CNI_REPO_SHA istio.deps -A 4 | grep lastStableSHA | cut -f 4 -d '"')
PROXY_REPO_SHA=$(grep PROXY_REPO_SHA istio.deps -A 4 | grep lastStableSHA | cut -f 4 -d '"')
API_REPO_SHA=$(grep "istio\.io/api" go.mod | cut -f 3 -d '-')
if [ -z "${ISTIO_REPO_SHA}" ] || [ -z "${API_REPO_SHA}" ] || [ -z "${PROXY_REPO_SHA}" ] || [ -z "${CNI_REPO_SHA}" ] ; then
echo "ISTIO_REPO_SHA:$ISTIO_REPO_SHA API_REPO_SHA:$API_REPO_SHA PROXY_REPO_SHA:$PROXY_REPO_SHA CNI_REPO_SHA:$CNI_REPO_SHA some shas not found"
exit 8
fi

pushd ../api || exit
API_SHA=$(git rev-parse "${API_REPO_SHA}")
popd || exit
cat << EOF > "${MANIFEST_FILE}"
istio ${ISTIO_REPO_SHA}
proxy ${PROXY_REPO_SHA}
api ${API_SHA}
cni ${CNI_REPO_SHA}
tools ${TOOLS_HEAD_SHA}
EOF


if [[ "${CB_VERIFY_CONSISTENCY}" == "true" ]]; then
pushd ../proxy || exit
PROXY_API_SHA=$(grep ISTIO_API istio.deps -A 4 | grep lastStableSHA | cut -f 4 -d '"')
popd || exit
if [[ "$PROXY_API_SHA" != "$API_REPO_SHA"* ]]; then
echo "inconsistent shas PROXY_API_SHA $PROXY_API_SHA != $API_REPO_SHA API_REPO_SHA" 1>&2
exit 17
fi
fi
}
60 changes: 15 additions & 45 deletions release/gcb/generate_manifest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ set -x

# shellcheck disable=SC1091
source "/workspace/gcb_env.sh"
# shellcheck disable=SC1091
# shellcheck disable=SC1090
source "${SCRIPTPATH}/gcb_lib.sh"

function checkout_code() {
local REPO=$1
Expand All @@ -42,50 +45,6 @@ function checkout_code() {
popd
}

function create_manifest_check_consistency() {
local MANIFEST_FILE=$1

pushd istio
local ISTIO_REPO_SHA
local PROXY_REPO_SHA
local CNI_REPO_SHA
local API_REPO_SHA
ISTIO_REPO_SHA=$(git rev-parse HEAD)
CNI_REPO_SHA=$(grep CNI_REPO_SHA istio.deps -A 4 | grep lastStableSHA | cut -f 4 -d '"')
PROXY_REPO_SHA=$(grep PROXY_REPO_SHA istio.deps -A 4 | grep lastStableSHA | cut -f 4 -d '"')
API_REPO_SHA=$(grep "istio\.io/api" go.mod | cut -f 3 -d '-')

if [ -z "${ISTIO_REPO_SHA}" ] || [ -z "${API_REPO_SHA}" ] || [ -z "${PROXY_REPO_SHA}" ] || [ -z "${CNI_REPO_SHA}" ] ; then
echo "ISTIO_REPO_SHA:$ISTIO_REPO_SHA API_REPO_SHA:$API_REPO_SHA PROXY_REPO_SHA:$PROXY_REPO_SHA CNI_REPO_SHA:$CNI_REPO_SHA some shas not found"
exit 8
fi
popd
checkout_code "api" "${API_REPO_SHA}" .
pushd api || exit
API_SHA=$(git rev-parse "${API_REPO_SHA}")
popd
cat << EOF > "${MANIFEST_FILE}"
istio ${ISTIO_REPO_SHA}
proxy ${PROXY_REPO_SHA}
api ${API_SHA}
cni ${CNI_REPO_SHA}
tools ${TOOLS_HEAD_SHA}
EOF


if [[ "${CB_VERIFY_CONSISTENCY}" == "true" ]]; then
# Consistency check not needed for CNI
checkout_code "proxy" "${PROXY_REPO_SHA}" .
pushd proxy
PROXY_API_SHA=$(grep ISTIO_API istio.deps -A 4 | grep lastStableSHA | cut -f 4 -d '"')
popd
if [[ "$PROXY_API_SHA" != "$API_REPO_SHA"* ]]; then
echo "inconsistent shas PROXY_API_SHA $PROXY_API_SHA != $API_REPO_SHA API_REPO_SHA" 1>&2
exit 17
fi
fi
}

# also sets ISTIO_HEAD_SHA variables
function istio_checkout_green_sha() {
pushd istio
Expand All @@ -99,6 +58,7 @@ function istio_checkout_green_sha() {
function istio_tools_get_green_sha() {
pushd tools
TOOLS_HEAD_SHA=$(git rev-parse HEAD)
export TOOLS_HEAD_SHA
popd
}

Expand Down Expand Up @@ -145,7 +105,17 @@ pushd "${CLONE_DIR}"

istio_checkout_green_sha "${MANIFEST_FILE}"
istio_check_green_sha_age
create_manifest_check_consistency "${MANIFEST_FILE}"

pushd istio
PROXY_REPO_SHA=$(grep PROXY_REPO_SHA istio.deps -A 4 | grep lastStableSHA | cut -f 4 -d '"')
API_REPO_SHA=$(grep "istio\.io/api" go.mod | cut -f 3 -d '-')
popd
checkout_code "proxy" "${PROXY_REPO_SHA}" .
checkout_code "api" "${API_REPO_SHA}" .

pushd istio
create_manifest_check_consistency "${MANIFEST_FILE}"
popd

#copy the needed files
# TODO figure out how to avoid need for copying to BASE_MANIFEST_URL
Expand Down
27 changes: 27 additions & 0 deletions release/gcb/local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash
set -x

# shellcheck disable=SC1091
source gcb_lib.sh
ROOT=$(cd "$(git rev-parse --show-cdup)" && pwd || return)
artifacts="$HOME/output/local"
export NEW_VERSION="fake"
export DOCKER_HUB='fake/fake'
GOPATH=$(cd "$ROOT/../../.." && pwd)
export GOPATH
echo "gopath is $GOPATH"

export CB_VERIFY_CONSISTENCY=true

echo "Delete old builds"
rm -r "${artifacts}" || echo
mkdir -p "${artifacts}"

pushd "${ROOT}/../tools" || exit
TOOLS_HEAD_SHA=$(git rev-parse HEAD)
export TOOLS_HEAD_SHA
popd || return

pushd "$ROOT" || exit
create_manifest_check_consistency "${artifacts}/manifest.txt"
popd || return

0 comments on commit d8b9a10

Please sign in to comment.