Skip to content

Commit

Permalink
Bazel release process scripts
Browse files Browse the repository at this point in the history
Those scripts are made to handle the soon to be Bazel
release process. It is still missing the CI part that
deploys built artifacts and sends announcement mails.

It uses the RELNOTES: tag (RELNOTES for a simple change,
RELNOTES[NEW] for a new feature, RELNOTES[INC] for an
incompatible change) to create the CHANGELOG.md file.

The main entry point is scripts/release/release.sh
and should be the only script called directly.

--
Change-Id: I6e066fda4d862ce793cc03dc8bdf0b8cb34f7c2c
Reviewed-on: https://bazel-review.googlesource.com/#/c/1580/
MOS_MIGRATED_REVID=99282250
  • Loading branch information
damienmg authored and lberki committed Jul 29, 2015
1 parent e4d8482 commit fa15d39
Show file tree
Hide file tree
Showing 4 changed files with 669 additions and 0 deletions.
21 changes: 21 additions & 0 deletions scripts/release/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,24 @@ sh_test(
":relnotes",
],
)

sh_library(
name = "release",
srcs = [
"common.sh",
"release.sh",
],
deps = [":relnotes"],
)

sh_test(
name = "release_test",
srcs = ["release_test.sh"],
data = [
"testenv.sh",
"//:git",
"//src/test/shell:bashunit",
],
tags = ["need_git"],
deps = [":release"],
)
61 changes: 61 additions & 0 deletions scripts/release/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/bin/bash -eu

# Copyright 2015 Google Inc. All rights reserved.
#
# 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.

# Some common method for release scripts

# A release candidate is created from a branch named "release-%name%"
# where %name% is the name of the release. Once promoted to a release,
# A tag %name% will be created from this branch and the corresponding
# branch removed.
# The last commit of the release branch is always a commit containing
# the release notes in the commit message and updating the CHANGELOG.md.
# This last commit will be cherry-picked back in the master branch
# when the release candidate is promoted to a release.
# To follow tracks and to support how CI systems fetch the refs, we
# store two commit notes: the release name and the candidate number.

# Returns the branch name of the current git repository
function git_get_branch() {
git symbolic-ref --short HEAD
}

# Show the commit message of the ref specified in argument
function git_commit_msg() {
git show -s --pretty=format:%B "$@"
}

# Extract the release candidate number from the git notes
function get_release_candidate() {
git notes --ref=release-candidate show "$@" 2>/dev/null | xargs echo || true
}

# Extract the release name from the git notes
function get_release_name() {
git notes --ref=release show "$@" 2>/dev/null | xargs echo || true
}

# Returns the info from the branch of the release. It is the current branch
# but it errors out if the current branch is not a release branch. This
# method returns the tag of the release and the number of the current
# candidate in this release.
function get_release_branch() {
local branch_name=$(git_get_branch)
if [ -z "$(get_release_name)" -o -z "$(get_release_candidate)" ]; then
echo "Not a release branch: ${branch_name}." >&2
exit 1
fi
echo "${branch_name}"
}
Loading

0 comments on commit fa15d39

Please sign in to comment.