deploy script enhancements (close #112) (#155)

[skip ci]
This commit is contained in:
Shahidh K Muhammed 2018-07-18 17:57:09 +05:30 committed by GitHub
parent 126fd754ed
commit 8aa481c639
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 6 deletions

View File

@ -1,16 +1,20 @@
#!/usr/bin/env bash
set -eo pipefail
set -evo pipefail
IFS=$'\n\t'
ROOT="$(readlink -f ${BASH_SOURCE[0]%/*}/../)"
LATEST_TAG=$(git describe --tags --abbrev=0)
PREVIOUS_TAG=$(git describe --tags $(git rev-list --tags --max-count=2) --abbrev=0 | sed -n 2p)
CHANGELOG_TEXT=$(git log ${PREVIOUS_TAG}..${LATEST_TAG} --pretty=format:'- %s' --reverse)
RELEASE_BODY=$(eval "cat <<EOF
$(<release_notes.template.md)
$(<$ROOT/.circleci/release_notes.template.md)
EOF
")
# reviewers for pull requests opened to update installation manifests
REVIEWERS="shahidhk,coco98,arvi3411301"
## deploy functions
deploy_server() {
echo "deploying server"
@ -23,12 +27,10 @@ deploy_server() {
deploy_server_latest() {
echo "deloying server latest tag"
cd "$ROOT/server"
docker login -u "$DOCKER_USER" -p "$DOCKER_PASSWORD"
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USER" --password-stdin
make push-latest
}
# TODO: open pull requests
draft_github_release() {
cd "$ROOT"
echo "drafting github release"
@ -40,6 +42,17 @@ draft_github_release() {
"$CIRCLE_TAG" /build/_cli_output/binaries/
}
send_pr_to_repo() {
git clone git@github.com:hasura/$1.git ~/$1
cd ~/$1
git checkout -b ${LATEST_TAG}
find . -type f -exec sed -i "s/\(hasura\/graphql-engine:\).*$/\1${LATEST_TAG}/" {} \;
git add .
git commit -m "update image version to ${LATEST_TAG}"
git push origin ${LATEST_TAG}
hub pull-request -F- <<<"Update image version to ${LATEST_TAG}" -r ${REVIEWERS} -a ${REVIEWERS}
}
deploy_console() {
echo "deploying console"
echo $GCLOUD_SERVICE_KEY > ${HOME}/gcloud-service-key.json
@ -85,4 +98,6 @@ deploy_server
if [[ ! -z "$CIRCLE_TAG" ]]; then
deploy_server_latest
draft_github_release
send_pr_to_repo graphql-engine-install-manifests
send_pr_to_repo graphql-engine-heroku
fi

View File

@ -4,6 +4,7 @@ ARG docker_ver="17.09.0-ce"
ARG upx_version="3.94"
ARG gcloud_version="207.0.0"
ARG ghr_version="0.10.0"
ARG hub_version="2.5.0"
RUN apt-get -y update \
&& apt-get -y upgrade \
@ -21,6 +22,9 @@ RUN apt-get -y update \
&& curl -Lo /tmp/gcloud-${gcloud_version}.tar.gz https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-${gcloud_version}-linux-x86_64.tar.gz \
&& tar -xzf /tmp/gcloud-${gcloud_version}.tar.gz -C /usr/local \
&& /usr/local/google-cloud-sdk/install.sh \
&& curl -Lo /tmp/hub-linux-amd64-${hub_version}.tgz https://github.com/github/hub/releases/download/v${hub_version}/hub-linux-amd64-${hub_version}.tgz \
&& tar -xz -C /tmp -f /tmp/hub-linux-amd64-${hub_version}.tgz \
&& mv /tmp/hub-linux-amd64-${hub_version}/bin/hub /usr/bin/ \
&& apt-get -y purge curl \
&& apt-get -y auto-remove \
&& apt-get -y clean \
@ -29,4 +33,4 @@ RUN apt-get -y update \
&& rm -rf /usr/share/man/ \
&& rm -rf /usr/share/locale/
ENV PATH "/usr/local/google-cloud-sdk/bin:$PATH"
ENV PATH "/usr/local/google-cloud-sdk/bin:$PATH"