Klaus Aehlig | 304a8a9 | 2017-01-19 16:40:21 +0000 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Damien Martin-Guillerez | ab13f68 | 2015-07-28 08:19:32 +0000 | [diff] [blame] | 2 | |
Damien Martin-Guillerez | f88f4d8 | 2015-09-25 13:56:55 +0000 | [diff] [blame] | 3 | # Copyright 2015 The Bazel Authors. All rights reserved. |
Damien Martin-Guillerez | ab13f68 | 2015-07-28 08:19:32 +0000 | [diff] [blame] | 4 | # |
| 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 Wollermann | a5afe95 | 2016-06-21 14:58:09 +0000 | [diff] [blame] | 17 | set -eu |
| 18 | |
Damien Martin-Guillerez | ab13f68 | 2015-07-28 08:19:32 +0000 | [diff] [blame] | 19 | # 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 |
| 23 | release_name= |
| 24 | git_hash= |
| 25 | url= |
| 26 | built_by= |
| 27 | build_log= |
Damien Martin-Guillerez | 0d35261 | 2016-12-02 13:48:14 +0000 | [diff] [blame] | 28 | release_notes= |
Damien Martin-Guillerez | ab13f68 | 2015-07-28 08:19:32 +0000 | [diff] [blame] | 29 | |
| 30 | for 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-Guillerez | 0d35261 | 2016-12-02 13:48:14 +0000 | [diff] [blame] | 47 | RELEASE_NOTES) |
| 48 | release_notes="$value" |
Damien Martin-Guillerez | ab13f68 | 2015-07-28 08:19:32 +0000 | [diff] [blame] | 49 | ;; |
| 50 | RELEASE_COMMIT_URL) |
| 51 | commit_url="$value" |
| 52 | ;; |
| 53 | esac |
| 54 | done <<<"$(cat $i)" |
| 55 | done |
| 56 | |
Kristina Chodorow | 2b1763a | 2015-09-01 09:15:54 +0000 | [diff] [blame] | 57 | url="${url:-https://github.com/bazelbuild/bazel/commit/${git_hash}}" |
Damien Martin-Guillerez | ab13f68 | 2015-07-28 08:19:32 +0000 | [diff] [blame] | 58 | |
| 59 | if [ -z "${release_name}" ]; then |
| 60 | # Not a release |
| 61 | echo "# Binary package at HEAD (@$git_hash)" |
| 62 | else |
Damien Martin-Guillerez | 0d35261 | 2016-12-02 13:48:14 +0000 | [diff] [blame] | 63 | echo "# ${release_notes}" # Make the first line the header |
Damien Martin-Guillerez | ab13f68 | 2015-07-28 08:19:32 +0000 | [diff] [blame] | 64 | # Subsection for environment |
| 65 | echo |
| 66 | echo "## Build informations" |
| 67 | fi |
| 68 | if [ -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 |
| 74 | elif [ -n "${build_log-}" ]; then |
| 75 | echo " - [Build log](${build_log})" |
| 76 | fi |
| 77 | |
| 78 | echo " - [Commit](${url})" |