Move to make for tag release workflow.
This will make tag & release workflows idempotent. PiperOrigin-RevId: 314154888
This commit is contained in:
parent
839208f118
commit
2c6c4365ea
10
Makefile
10
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.
|
||||
##
|
||||
|
|
|
@ -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 <<EOF
|
||||
protocol=https
|
||||
host=github.com
|
||||
username=$(cat "${KOKORO_KEYSTORE_DIR}/${KOKORO_GITHUB_ACCESS_TOKEN}")
|
||||
password=x-oauth-basic
|
||||
EOF
|
||||
fi
|
||||
|
||||
# Run the release tool, which pushes to the origin repository.
|
||||
tools/tag_release.sh \
|
||||
"${KOKORO_RELEASE_COMMIT}" \
|
||||
"${KOKORO_RELEASE_TAG}" \
|
||||
"${KOKORO_ARTIFACTS_DIR}/${KOKORO_RELNOTES}"
|
|
@ -18,10 +18,10 @@
|
|||
# validate a provided release name, create a tag and push it. It must be
|
||||
# run manually when a release is created.
|
||||
|
||||
set -xeu
|
||||
set -xeuo pipefail
|
||||
|
||||
# Check arguments.
|
||||
if [ "$#" -ne 3 ]; then
|
||||
if [[ "$#" -ne 3 ]]; then
|
||||
echo "usage: $0 <commit|revid> <release.rc> <message-file>"
|
||||
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: <commit|revid> is empty."
|
||||
fi
|
||||
if [[ -z "${release}" ]]; then
|
||||
echo "error: <release.rc> 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}"
|
||||
|
|
Loading…
Reference in New Issue