blob: dc4f08eccc5899ca2f74d3b8e8ca75e33b9d0a66 [file] [log] [blame]
Klaus Aehlig304a8a92017-01-19 16:40:21 +00001#!/usr/bin/env bash
Damien Martin-Guillerezab13f682015-07-28 08:19:32 +00002
Damien Martin-Guillerezf88f4d82015-09-25 13:56:55 +00003# Copyright 2015 The Bazel Authors. All rights reserved.
Damien Martin-Guillerezab13f682015-07-28 08:19:32 +00004#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
Philipp Wollermanna5afe952016-06-21 14:58:09 +000017set -eu
18
Damien Martin-Guillerezab13f682015-07-28 08:19:32 +000019# Generate a README.md for the package from the information provided
20# by the build status command.
21
22# Store the build status information we care about
23release_name=
24git_hash=
25url=
26built_by=
27build_log=
Damien Martin-Guillerez0d352612016-12-02 13:48:14 +000028release_notes=
Damien Martin-Guillerezab13f682015-07-28 08:19:32 +000029
30for i in "${@}"; do
31 while read line; do
32 key=$(echo "$line" | cut -d " " -f 1)
33 value="$(echo "$line" | cut -d " " -f 2- | tr '\f' '\n')"
34 case $key in
35 RELEASE_NAME)
36 release_name="$value"
37 ;;
38 RELEASE_GIT_HASH)
39 git_hash="$value"
40 ;;
41 RELEASE_BUILT_BY)
42 built_by="$value"
43 ;;
44 RELEASE_BUILD_LOG)
45 build_log="$value"
46 ;;
Damien Martin-Guillerez0d352612016-12-02 13:48:14 +000047 RELEASE_NOTES)
48 release_notes="$value"
Damien Martin-Guillerezab13f682015-07-28 08:19:32 +000049 ;;
50 RELEASE_COMMIT_URL)
51 commit_url="$value"
52 ;;
53 esac
54 done <<<"$(cat $i)"
55done
56
Kristina Chodorow2b1763a2015-09-01 09:15:54 +000057url="${url:-https://github.com/bazelbuild/bazel/commit/${git_hash}}"
Damien Martin-Guillerezab13f682015-07-28 08:19:32 +000058
59if [ -z "${release_name}" ]; then
60 # Not a release
61 echo "# Binary package at HEAD (@$git_hash)"
62else
Damien Martin-Guillerez0d352612016-12-02 13:48:14 +000063 echo "# ${release_notes}" # Make the first line the header
Damien Martin-Guillerezab13f682015-07-28 08:19:32 +000064 # Subsection for environment
65 echo
66 echo "## Build informations"
67fi
68if [ -n "${built_by-}" ]; then
69 if [ -n "${build_log}" ]; then
70 echo " - [Built by ${built_by}](${build_log})"
71 else
72 echo " - Built by ${built_by}"
73 fi
74elif [ -n "${build_log-}" ]; then
75 echo " - [Build log](${build_log})"
76fi
77
78echo " - [Commit](${url})"