From b6a00aa375e674617f1914b90db5ddb222b5a04e Mon Sep 17 00:00:00 2001 From: Adin Scannell Date: Wed, 20 Nov 2019 15:28:02 -0800 Subject: Use a GitHub credential for tagging a release. PiperOrigin-RevId: 281617882 --- scripts/release.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'scripts/release.sh') diff --git a/scripts/release.sh b/scripts/release.sh index b936bcc77..091abf87f 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -34,5 +34,16 @@ declare -r EMAIL=${EMAIL:-${KOKORO_RELEASE_AUTHOR}@google.com} git config --get user.name || git config user.name "gVisor-bot" git config --get user.email || git config user.email "${EMAIL}" +# Provide a credential if available. +if [[ -v KOKORO_GITHUB_ACCESS_TOKEN ]]; then + git config --global credential.helper cache + git credential approve < Date: Thu, 27 Feb 2020 10:21:33 -0800 Subject: Use automated release notes, if available. PiperOrigin-RevId: 297628615 --- scripts/release.sh | 13 ++++++++++++- tools/tag_release.sh | 12 +++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) (limited to 'scripts/release.sh') diff --git a/scripts/release.sh b/scripts/release.sh index 091abf87f..e14ba04a7 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -25,6 +25,14 @@ if ! [[ -v KOKORO_RELEASE_TAG ]]; then echo "No KOKORO_RELEASE_TAG provided." >&2 exit 1 fi +if ! [[ -v KOKORO_RELNOTES ]]; then + echo "No KOKORO_RELNOTES provided." >&2 + exit 1 +fi +if ! [[ -r "${KOKORO_ARTIFACTS_DIR}/${KOKORO_RELNOTES}" ]]; then + echo "The file '${KOKORO_ARTIFACTS_DIR}/${KOKORO_RELNOTES}' is not readable." >&2 + exit 1 +fi # Unless an explicit releaser is provided, use the bot e-mail. declare -r KOKORO_RELEASE_AUTHOR=${KOKORO_RELEASE_AUTHOR:-gvisor-bot} @@ -46,4 +54,7 @@ EOF fi # Run the release tool, which pushes to the origin repository. -tools/tag_release.sh "${KOKORO_RELEASE_COMMIT}" "${KOKORO_RELEASE_TAG}" +tools/tag_release.sh \ + "${KOKORO_RELEASE_COMMIT}" \ + "${KOKORO_RELEASE_TAG}" \ + "${KOKORO_ARTIFACTS_DIR}/${KOKORO_RELNOTES}" diff --git a/tools/tag_release.sh b/tools/tag_release.sh index f33b902d6..4dbfe420a 100755 --- a/tools/tag_release.sh +++ b/tools/tag_release.sh @@ -21,13 +21,19 @@ set -xeu # Check arguments. -if [ "$#" -ne 2 ]; then - echo "usage: $0 " +if [ "$#" -ne 3 ]; then + echo "usage: $0 " exit 1 fi declare -r target_commit="$1" declare -r release="$2" +declare -r message_file="$3" + +if ! [[ -r "${message_file}" ]]; then + echo "error: message file '${message_file}' is not readable." + exit 1 +fi closest_commit() { while read line; do @@ -64,6 +70,6 @@ fi # Tag the given commit (annotated, to record the committer). declare -r tag="release-${release}" -(git tag -m "Release ${release}" -a "${tag}" "${commit}" && \ +(git tag -F "${message_file}" -a "${tag}" "${commit}" && \ git push origin tag "${tag}") || \ (git tag -d "${tag}" && false) -- cgit v1.2.3 From 470633d7e916e7956f4ebd75559f92cf12067cbf Mon Sep 17 00:00:00 2001 From: Ting-Yu Wang Date: Mon, 20 Apr 2020 12:57:18 -0700 Subject: Fix release.sh. git commands need to be run in git repo. PiperOrigin-RevId: 307458938 --- scripts/release.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'scripts/release.sh') diff --git a/scripts/release.sh b/scripts/release.sh index e14ba04a7..ac7eff3ef 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -14,7 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -source $(dirname $0)/common.sh +cd $(dirname $0)/.. +source scripts/common.sh # Tag a release only if provided. if ! [[ -v KOKORO_RELEASE_COMMIT ]]; then -- cgit v1.2.3 From 2c6c4365ea3ad23166353aa03643fc009669ee93 Mon Sep 17 00:00:00 2001 From: Adin Scannell Date: Mon, 1 Jun 2020 10:27:59 -0700 Subject: Move to make for tag release workflow. This will make tag & release workflows idempotent. PiperOrigin-RevId: 314154888 --- Makefile | 10 +++++++++ scripts/release.sh | 61 ---------------------------------------------------- tools/tag_release.sh | 19 ++++++++++------ 3 files changed, 23 insertions(+), 67 deletions(-) delete mode 100755 scripts/release.sh (limited to 'scripts/release.sh') diff --git a/Makefile b/Makefile index 4d66b0904..9d486ef49 100644 --- a/Makefile +++ b/Makefile @@ -158,10 +158,16 @@ website-deploy: website-push ## Deploy a new version of the website. ## RELEASE_ROOT - The repository root (default: "repo" directory). ## RELEASE_KEY - The repository GPG private key file (default: dummy key is created). ## RELEASE_NIGHTLY - Set to true if a nightly release (default: false). +## RELEASE_COMMIT - The commit or Change-Id for the release (needed for tag). +## RELEASE_NAME - The name of the release in the proper format (needed for tag). +## RELEASE_NOTES - The file containing release notes (needed for tag). ## RELEASE_ROOT := $(CURDIR)/repo RELEASE_KEY := repo.key RELEASE_NIGHTLY := false +RELEASE_COMMIT := +RELEASE_NAME := +RELEASE_NOTES := $(RELEASE_KEY): @echo "WARNING: Generating a key for testing ($@); don't use this." @@ -179,6 +185,10 @@ release: $(RELEASE_KEY) ## Builds a release. rc=$$?; rm -rf $$T; exit $$rc .PHONY: release +tag: ## Creates and pushes a release tag. + @tools/tag_release.sh "$(RELEASE_COMMIT)" "$(RELEASE_NAME)" "$(RELEASE_NOTES)" +.PHONY: tag + ## ## Development helpers and tooling. ## diff --git a/scripts/release.sh b/scripts/release.sh deleted file mode 100755 index ac7eff3ef..000000000 --- a/scripts/release.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/bash - -# Copyright 2018 The gVisor Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -cd $(dirname $0)/.. -source scripts/common.sh - -# Tag a release only if provided. -if ! [[ -v KOKORO_RELEASE_COMMIT ]]; then - echo "No KOKORO_RELEASE_COMMIT provided." >&2 - exit 1 -fi -if ! [[ -v KOKORO_RELEASE_TAG ]]; then - echo "No KOKORO_RELEASE_TAG provided." >&2 - exit 1 -fi -if ! [[ -v KOKORO_RELNOTES ]]; then - echo "No KOKORO_RELNOTES provided." >&2 - exit 1 -fi -if ! [[ -r "${KOKORO_ARTIFACTS_DIR}/${KOKORO_RELNOTES}" ]]; then - echo "The file '${KOKORO_ARTIFACTS_DIR}/${KOKORO_RELNOTES}' is not readable." >&2 - exit 1 -fi - -# Unless an explicit releaser is provided, use the bot e-mail. -declare -r KOKORO_RELEASE_AUTHOR=${KOKORO_RELEASE_AUTHOR:-gvisor-bot} -declare -r EMAIL=${EMAIL:-${KOKORO_RELEASE_AUTHOR}@google.com} - -# Ensure we have an appropriate configuration for the tag. -git config --get user.name || git config user.name "gVisor-bot" -git config --get user.email || git config user.email "${EMAIL}" - -# Provide a credential if available. -if [[ -v KOKORO_GITHUB_ACCESS_TOKEN ]]; then - git config --global credential.helper cache - git credential approve < " exit 1 fi @@ -30,6 +30,12 @@ declare -r target_commit="$1" declare -r release="$2" declare -r message_file="$3" +if [[ -z "${target_commit}" ]]; then + echo "error: is empty." +fi +if [[ -z "${release}" ]]; then + echo "error: is empty." +fi if ! [[ -r "${message_file}" ]]; then echo "error: message file '${message_file}' is not readable." exit 1 @@ -68,8 +74,9 @@ if ! [[ "${release}" =~ ^20[0-9]{6}\.[0-9]+$ ]]; then exit 1 fi -# Tag the given commit (annotated, to record the committer). +# Tag the given commit (annotated, to record the committer). Note that the tag +# here is applied as a force, in case the tag already exists and is the same. +# The push will fail in this case (because it is not forced). declare -r tag="release-${release}" -(git tag -F "${message_file}" -a "${tag}" "${commit}" && \ - git push origin tag "${tag}") || \ - (git tag -d "${tag}" && false) +git tag -f -F "${message_file}" -a "${tag}" "${commit}" && \ + git push origin tag "${tag}" -- cgit v1.2.3