Philipp Wollermann | a5afe95 | 2016-06-21 14:58:09 +0000 | [diff] [blame] | 1 | #!/bin/bash |
Damien Martin-Guillerez | f7a3931 | 2015-08-17 08:32:09 +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 | f7a3931 | 2015-08-17 08:32:09 +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 | f7a3931 | 2015-08-17 08:32:09 +0000 | [diff] [blame] | 19 | # Main deploy functions for the continous build system |
| 20 | # Just source this file and use the various method: |
| 21 | # bazel_build build bazel and run all its test |
| 22 | # bazel_release use the artifact generated by bazel_build and push |
| 23 | # them to github for a release and to GCS for a release candidate. |
| 24 | # Also prepare an email for announcing the release. |
| 25 | |
| 26 | # Load common.sh |
Philipp Wollermann | 5fabb43 | 2018-03-27 04:37:23 -0700 | [diff] [blame] | 27 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| 28 | source "$(dirname ${SCRIPT_DIR})/release/common.sh" |
Damien Martin-Guillerez | f7a3931 | 2015-08-17 08:32:09 +0000 | [diff] [blame] | 29 | |
Philipp Wollermann | 5fabb43 | 2018-03-27 04:37:23 -0700 | [diff] [blame] | 30 | if ! command -v gsutil &>/dev/null; then |
| 31 | echo "Required tool 'gsutil' not found. Please install it:" |
| 32 | echo "See https://cloud.google.com/sdk/downloads for instructions." |
| 33 | exit 1 |
| 34 | fi |
| 35 | if ! command -v github-release &>/dev/null; then |
| 36 | echo "Required tool 'github-release' not found. Download it from here:" |
| 37 | echo "https://github.com/c4milo/github-release/releases" |
| 38 | echo "Just extract the archive and put the binary on your PATH." |
| 39 | exit 1 |
| 40 | fi |
| 41 | if ! command -v debsign &>/dev/null; then |
| 42 | echo "Required tool 'debsign' not found. Please install it via apt-get:" |
| 43 | echo "apt-get install devscripts" |
| 44 | exit 1 |
| 45 | fi |
| 46 | if ! command -v reprepro &>/dev/null; then |
| 47 | echo "Required tool 'reprepro' not found. Please install it via apt-get:" |
| 48 | echo "apt-get install reprepro" |
| 49 | exit 1 |
| 50 | fi |
| 51 | if ! command -v gpg &>/dev/null; then |
| 52 | echo "Required tool 'gpg' not found. Please install it via apt-get:" |
| 53 | echo "apt-get install gnupg" |
| 54 | exit 1 |
| 55 | fi |
| 56 | if ! command -v pandoc &>/dev/null; then |
| 57 | echo "Required tool 'pandoc' not found. Please install it via apt-get:" |
| 58 | echo "apt-get install pandoc" |
| 59 | exit 1 |
| 60 | fi |
| 61 | # if ! command -v ssmtp &>/dev/null; then |
| 62 | # echo "Required tool 'ssmtp' not found. Please install it via apt-get:" |
| 63 | # echo "apt-get install ssmtp" |
| 64 | # exit 1 |
| 65 | # fi |
Damien Martin-Guillerez | f7a3931 | 2015-08-17 08:32:09 +0000 | [diff] [blame] | 66 | |
philwo | ead5847 | 2019-05-10 08:23:25 -0700 | [diff] [blame] | 67 | export APT_GPG_KEY_ID=$(gsutil cat gs://bazel-trusted-encrypted-secrets/release-key.gpg.id) |
Klaus Aehlig | 736c46d | 2016-11-10 16:09:34 +0000 | [diff] [blame] | 68 | |
Damien Martin-Guillerez | f7a3931 | 2015-08-17 08:32:09 +0000 | [diff] [blame] | 69 | # Generate a string from a template and a list of substitutions. |
| 70 | # The first parameter is the template name and each subsequent parameter |
| 71 | # is taken as a couple: first is the string the substitute and the second |
| 72 | # is the result of the substitution. |
| 73 | function generate_from_template() { |
| 74 | local value="$1" |
| 75 | shift |
| 76 | while (( $# >= 2 )); do |
| 77 | value="${value//$1/$2}" |
| 78 | shift 2 |
| 79 | done |
| 80 | echo "${value}" |
| 81 | } |
| 82 | |
| 83 | # Generate the email for the release. |
| 84 | # The first line of the output will be the recipient, the second line |
| 85 | # the mail subjects and the subsequent lines the mail, its content. |
| 86 | # If no planed release, then this function output will be empty. |
| 87 | function generate_email() { |
Philipp Wollermann | 5fabb43 | 2018-03-27 04:37:23 -0700 | [diff] [blame] | 88 | RELEASE_CANDIDATE_URL="https://releases.bazel.build/%release_name%/rc%rc%/index.html" |
| 89 | RELEASE_URL="https://github.com/bazelbuild/bazel/releases/tag/%release_name%" |
| 90 | |
Damien Martin-Guillerez | f7a3931 | 2015-08-17 08:32:09 +0000 | [diff] [blame] | 91 | local release_name=$(get_release_name) |
| 92 | local rc=$(get_release_candidate) |
| 93 | local args=( |
| 94 | "%release_name%" "${release_name}" |
| 95 | "%rc%" "${rc}" |
Damien Martin-Guillerez | acbcbc2 | 2016-12-20 07:40:42 +0000 | [diff] [blame] | 96 | "%relnotes%" "# $(get_full_release_notes)" |
Damien Martin-Guillerez | f7a3931 | 2015-08-17 08:32:09 +0000 | [diff] [blame] | 97 | ) |
| 98 | if [ -n "${rc}" ]; then |
| 99 | args+=( |
Philipp Wollermann | 5fabb43 | 2018-03-27 04:37:23 -0700 | [diff] [blame] | 100 | "%url%" "$(generate_from_template "${RELEASE_CANDIDATE_URL}" "${args[@]}")" |
Damien Martin-Guillerez | f7a3931 | 2015-08-17 08:32:09 +0000 | [diff] [blame] | 101 | ) |
Philipp Wollermann | 5fabb43 | 2018-03-27 04:37:23 -0700 | [diff] [blame] | 102 | generate_from_template \ |
| 103 | "$(cat "${SCRIPT_DIR}/rc_email.txt")" \ |
| 104 | "${args[@]}" |
Damien Martin-Guillerez | f7a3931 | 2015-08-17 08:32:09 +0000 | [diff] [blame] | 105 | elif [ -n "${release_name}" ]; then |
| 106 | args+=( |
Philipp Wollermann | 5fabb43 | 2018-03-27 04:37:23 -0700 | [diff] [blame] | 107 | "%url%" "$(generate_from_template "${RELEASE_URL}" "${args[@]}")" |
Damien Martin-Guillerez | f7a3931 | 2015-08-17 08:32:09 +0000 | [diff] [blame] | 108 | ) |
Philipp Wollermann | 5fabb43 | 2018-03-27 04:37:23 -0700 | [diff] [blame] | 109 | generate_from_template \ |
| 110 | "$(cat "${SCRIPT_DIR}/release_email.txt")" "${args[@]}" |
Damien Martin-Guillerez | f7a3931 | 2015-08-17 08:32:09 +0000 | [diff] [blame] | 111 | fi |
| 112 | } |
| 113 | |
dmarting | 5e57663 | 2017-07-24 19:01:08 +0200 | [diff] [blame] | 114 | function get_release_page() { |
Damien Martin-Guillerez | b6e29ca | 2017-07-26 16:06:44 +0200 | [diff] [blame] | 115 | echo "# $(get_full_release_notes)"' |
Damien Martin-Guillerez | bf2e4ee | 2016-07-06 10:04:34 +0000 | [diff] [blame] | 116 | |
| 117 | _Notice_: Bazel installers contain binaries licensed under the GPLv2 with |
| 118 | Classpath exception. Those installers should always be redistributed along with |
Damien Martin-Guillerez | 671045b | 2016-10-11 14:17:28 +0000 | [diff] [blame] | 119 | the source code. |
| 120 | |
Philipp Wollermann | 9504827 | 2017-03-17 15:11:58 +0000 | [diff] [blame] | 121 | Some versions of Bazel contain a bundled version of OpenJDK. The license of the |
| 122 | bundled OpenJDK and other open-source components can be displayed by running |
| 123 | the command `bazel license`. The vendor and version information of the bundled |
| 124 | OpenJDK can be displayed by running the command `bazel info java-runtime`. |
| 125 | The binaries and source-code of the bundled OpenJDK can be |
dmarting | e17f890 | 2017-07-27 13:55:10 +0200 | [diff] [blame] | 126 | [downloaded from our mirror server](https://mirror.bazel.build/openjdk/index.html). |
Philipp Wollermann | 9504827 | 2017-03-17 15:11:58 +0000 | [diff] [blame] | 127 | |
Damien Martin-Guillerez | 671045b | 2016-10-11 14:17:28 +0000 | [diff] [blame] | 128 | _Security_: All our binaries are signed with our |
Klaus Aehlig | baccf24 | 2016-10-28 17:37:35 +0000 | [diff] [blame] | 129 | [public key](https://bazel.build/bazel-release.pub.gpg) 48457EE0. |
Damien Martin-Guillerez | 24795d4 | 2017-06-27 11:01:29 +0200 | [diff] [blame] | 130 | ' |
dmarting | 5e57663 | 2017-07-24 19:01:08 +0200 | [diff] [blame] | 131 | } |
Damien Martin-Guillerez | bf2e4ee | 2016-07-06 10:04:34 +0000 | [diff] [blame] | 132 | |
dmarting | 5e57663 | 2017-07-24 19:01:08 +0200 | [diff] [blame] | 133 | # Deploy a github release using a third party tool: |
| 134 | # https://github.com/c4milo/github-release |
| 135 | # This methods expects the following arguments: |
| 136 | # $1..$n files generated by package_build (should not contains the README file) |
Philipp Wollermann | 5fabb43 | 2018-03-27 04:37:23 -0700 | [diff] [blame] | 137 | # Please set GITHUB_TOKEN to talk to the Github API. |
dmarting | 5e57663 | 2017-07-24 19:01:08 +0200 | [diff] [blame] | 138 | function release_to_github() { |
Philipp Wollermann | 5fabb43 | 2018-03-27 04:37:23 -0700 | [diff] [blame] | 139 | local artifact_dir="$1" |
| 140 | |
dmarting | 5e57663 | 2017-07-24 19:01:08 +0200 | [diff] [blame] | 141 | local release_name=$(get_release_name) |
| 142 | local rc=$(get_release_candidate) |
dmarting | 5e57663 | 2017-07-24 19:01:08 +0200 | [diff] [blame] | 143 | |
Damien Martin-Guillerez | f7a3931 | 2015-08-17 08:32:09 +0000 | [diff] [blame] | 144 | if [ -n "${release_name}" ] && [ -z "${rc}" ]; then |
philwo | b8d0e1b | 2019-01-17 04:12:08 -0800 | [diff] [blame] | 145 | local github_token="$(gsutil cat gs://bazel-trusted-encrypted-secrets/github-trusted-token.enc | \ |
| 146 | gcloud kms decrypt --project bazel-public --location global --keyring buildkite --key github-trusted-token --ciphertext-file - --plaintext-file -)" |
Philipp Wollermann | 5fabb43 | 2018-03-27 04:37:23 -0700 | [diff] [blame] | 147 | |
philwo | b8d0e1b | 2019-01-17 04:12:08 -0800 | [diff] [blame] | 148 | GITHUB_TOKEN="${github_token}" github-release "bazelbuild/bazel" "${release_name}" "" "$(get_release_page)" "${artifact_dir}/*" |
Damien Martin-Guillerez | f7a3931 | 2015-08-17 08:32:09 +0000 | [diff] [blame] | 149 | fi |
| 150 | } |
| 151 | |
Philipp Wollermann | 5fabb43 | 2018-03-27 04:37:23 -0700 | [diff] [blame] | 152 | # Creates an index of the files contained in folder $1 in Markdown format. |
Damien Martin-Guillerez | f7a3931 | 2015-08-17 08:32:09 +0000 | [diff] [blame] | 153 | function create_index_md() { |
dmarting | 5e57663 | 2017-07-24 19:01:08 +0200 | [diff] [blame] | 154 | # First, add the release notes |
| 155 | get_release_page |
Damien Martin-Guillerez | f7a3931 | 2015-08-17 08:32:09 +0000 | [diff] [blame] | 156 | # Then, add the list of files |
| 157 | echo |
| 158 | echo "## Index of files" |
| 159 | echo |
| 160 | for f in $1/*.sha256; do # just list the sha256 ones |
| 161 | local filename=$(basename $f .sha256); |
Damien Martin-Guillerez | 671045b | 2016-10-11 14:17:28 +0000 | [diff] [blame] | 162 | echo " - [${filename}](${filename}) [[SHA-256](${filename}.sha256)] [[SIG](${filename}.sig)]" |
Damien Martin-Guillerez | f7a3931 | 2015-08-17 08:32:09 +0000 | [diff] [blame] | 163 | done |
| 164 | } |
| 165 | |
Philipp Wollermann | 5fabb43 | 2018-03-27 04:37:23 -0700 | [diff] [blame] | 166 | # Creates an index of the files contained in folder $1 in HTML format. |
Damien Martin-Guillerez | f7a3931 | 2015-08-17 08:32:09 +0000 | [diff] [blame] | 167 | function create_index_html() { |
Philipp Wollermann | 5fabb43 | 2018-03-27 04:37:23 -0700 | [diff] [blame] | 168 | create_index_md "${@}" | pandoc -f markdown -t html |
Yun Peng | 70b29f4 | 2016-05-24 18:04:37 +0000 | [diff] [blame] | 169 | } |
| 170 | |
Damien Martin-Guillerez | f7a3931 | 2015-08-17 08:32:09 +0000 | [diff] [blame] | 171 | # Deploy a release candidate to Google Cloud Storage. |
| 172 | # It requires to have gsutil installed. You can force the path to gsutil |
Philipp Wollermann | 5fabb43 | 2018-03-27 04:37:23 -0700 | [diff] [blame] | 173 | # by setting the GSUTIL environment variable. |
Damien Martin-Guillerez | f7a3931 | 2015-08-17 08:32:09 +0000 | [diff] [blame] | 174 | # This methods expects the following arguments: |
| 175 | # $1..$n files generated by package_build |
| 176 | function release_to_gcs() { |
Philipp Wollermann | 5fabb43 | 2018-03-27 04:37:23 -0700 | [diff] [blame] | 177 | local artifact_dir="$1" |
| 178 | |
Yun Peng | 70b29f4 | 2016-05-24 18:04:37 +0000 | [diff] [blame] | 179 | local release_name="$(get_release_name)" |
| 180 | local rc="$(get_release_candidate)" |
Philipp Wollermann | 5fabb43 | 2018-03-27 04:37:23 -0700 | [diff] [blame] | 181 | |
dmarting | ebe36f2 | 2017-03-29 12:25:01 +0000 | [diff] [blame] | 182 | if [ -n "${release_name}" ]; then |
dmarting | c58ba09 | 2017-05-04 12:38:16 +0200 | [diff] [blame] | 183 | local release_path="${release_name}/release" |
dmarting | ebe36f2 | 2017-03-29 12:25:01 +0000 | [diff] [blame] | 184 | if [ -n "${rc}" ]; then |
| 185 | release_path="${release_name}/rc${rc}" |
| 186 | fi |
Philipp Wollermann | 5fabb43 | 2018-03-27 04:37:23 -0700 | [diff] [blame] | 187 | create_index_html "${artifact_dir}" > "${artifact_dir}/index.html" |
philwo | 3bbf9b9d | 2019-04-17 07:05:01 -0700 | [diff] [blame] | 188 | gsutil -m cp "${artifact_dir}/**" "gs://bazel/${release_path}" |
Yun Peng | 70b29f4 | 2016-05-24 18:04:37 +0000 | [diff] [blame] | 189 | fi |
| 190 | } |
| 191 | |
Yun Peng | 3d8ae22 | 2016-10-11 13:02:42 +0000 | [diff] [blame] | 192 | function ensure_gpg_secret_key_imported() { |
Philipp Wollermann | 5fabb43 | 2018-03-27 04:37:23 -0700 | [diff] [blame] | 193 | if ! gpg --list-secret-keys | grep "${APT_GPG_KEY_ID}" > /dev/null; then |
| 194 | keyfile=$(mktemp --tmpdir) |
| 195 | chmod 0600 "${keyfile}" |
philwo | ead5847 | 2019-05-10 08:23:25 -0700 | [diff] [blame] | 196 | gsutil cat "gs://bazel-trusted-encrypted-secrets/release-key.gpg.enc" | \ |
philwo | 8ab0907 | 2018-04-25 12:57:20 -0700 | [diff] [blame] | 197 | gcloud kms decrypt --location "global" --keyring "buildkite" --key "bazel-release-key" --ciphertext-file "-" --plaintext-file "${keyfile}" |
Philipp Wollermann | 5fabb43 | 2018-03-27 04:37:23 -0700 | [diff] [blame] | 198 | gpg --allow-secret-key-import --import "${keyfile}" |
| 199 | rm -f "${keyfile}" |
| 200 | fi |
| 201 | |
Yun Peng | 2d1d492 | 2016-11-15 13:33:47 +0000 | [diff] [blame] | 202 | # Make sure we use stronger digest algorithm。 |
| 203 | # We use reprepro to generate the debian repository, |
| 204 | # but there's no way to pass flags to gpg using reprepro, so writting it into |
| 205 | # ~/.gnupg/gpg.conf |
Philipp Wollermann | 5fabb43 | 2018-03-27 04:37:23 -0700 | [diff] [blame] | 206 | if ! grep "digest-algo sha256" ~/.gnupg/gpg.conf > /dev/null; then |
| 207 | echo "digest-algo sha256" >> ~/.gnupg/gpg.conf |
| 208 | fi |
Yun Peng | 3d8ae22 | 2016-10-11 13:02:42 +0000 | [diff] [blame] | 209 | } |
| 210 | |
Yun Peng | 70b29f4 | 2016-05-24 18:04:37 +0000 | [diff] [blame] | 211 | function create_apt_repository() { |
| 212 | mkdir conf |
| 213 | cat > conf/distributions <<EOF |
| 214 | Origin: Bazel Authors |
| 215 | Label: Bazel |
| 216 | Codename: stable |
Yun Peng | 55e042a | 2016-07-26 13:36:42 +0000 | [diff] [blame] | 217 | Architectures: amd64 source |
Damien Martin-Guillerez | c616acc | 2017-06-27 10:49:01 +0200 | [diff] [blame] | 218 | Components: jdk1.8 |
Yun Peng | 70b29f4 | 2016-05-24 18:04:37 +0000 | [diff] [blame] | 219 | Description: Bazel APT Repository |
| 220 | DebOverride: override.stable |
| 221 | DscOverride: override.stable |
| 222 | SignWith: ${APT_GPG_KEY_ID} |
| 223 | |
| 224 | Origin: Bazel Authors |
| 225 | Label: Bazel |
| 226 | Codename: testing |
Yun Peng | 55e042a | 2016-07-26 13:36:42 +0000 | [diff] [blame] | 227 | Architectures: amd64 source |
Damien Martin-Guillerez | c616acc | 2017-06-27 10:49:01 +0200 | [diff] [blame] | 228 | Components: jdk1.8 |
Yun Peng | 70b29f4 | 2016-05-24 18:04:37 +0000 | [diff] [blame] | 229 | Description: Bazel APT Repository |
| 230 | DebOverride: override.testing |
| 231 | DscOverride: override.testing |
| 232 | SignWith: ${APT_GPG_KEY_ID} |
| 233 | EOF |
| 234 | |
| 235 | cat > conf/options <<EOF |
| 236 | verbose |
| 237 | ask-passphrase |
| 238 | basedir . |
| 239 | EOF |
| 240 | |
Damien Martin-Guillerez | 4fb378c | 2016-12-20 11:04:02 +0000 | [diff] [blame] | 241 | # TODO(#2264): this is a quick workaround #2256, figure out a correct fix. |
| 242 | cat > conf/override.stable <<EOF |
| 243 | bazel Section contrib/devel |
| 244 | bazel Priority optional |
| 245 | EOF |
| 246 | cat > conf/override.testing <<EOF |
| 247 | bazel Section contrib/devel |
| 248 | bazel Priority optional |
| 249 | EOF |
Yun Peng | 70b29f4 | 2016-05-24 18:04:37 +0000 | [diff] [blame] | 250 | |
Yun Peng | 3d8ae22 | 2016-10-11 13:02:42 +0000 | [diff] [blame] | 251 | ensure_gpg_secret_key_imported |
Yun Peng | 70b29f4 | 2016-05-24 18:04:37 +0000 | [diff] [blame] | 252 | |
| 253 | local distribution="$1" |
Philipp Wollermann | 5fabb43 | 2018-03-27 04:37:23 -0700 | [diff] [blame] | 254 | local deb_pkg_name="$2" |
Damien Martin-Guillerez | c616acc | 2017-06-27 10:49:01 +0200 | [diff] [blame] | 255 | local deb_dsc_name="$3" |
Yun Peng | 55e042a | 2016-07-26 13:36:42 +0000 | [diff] [blame] | 256 | |
Philipp Wollermann | 5fabb43 | 2018-03-27 04:37:23 -0700 | [diff] [blame] | 257 | debsign -k "${APT_GPG_KEY_ID}" "${deb_dsc_name}" |
Yun Peng | 55e042a | 2016-07-26 13:36:42 +0000 | [diff] [blame] | 258 | |
Philipp Wollermann | 5fabb43 | 2018-03-27 04:37:23 -0700 | [diff] [blame] | 259 | reprepro -C jdk1.8 includedeb "${distribution}" "${deb_pkg_name}" |
Yun Peng | 55e042a | 2016-07-26 13:36:42 +0000 | [diff] [blame] | 260 | reprepro -C jdk1.8 includedsc "${distribution}" "${deb_dsc_name}" |
Yun Peng | 70b29f4 | 2016-05-24 18:04:37 +0000 | [diff] [blame] | 261 | |
philwo | 3bbf9b9d | 2019-04-17 07:05:01 -0700 | [diff] [blame] | 262 | gsutil -m cp -r dists pool "gs://bazel-apt" |
Yun Peng | 70b29f4 | 2016-05-24 18:04:37 +0000 | [diff] [blame] | 263 | } |
| 264 | |
| 265 | function release_to_apt() { |
Philipp Wollermann | 5fabb43 | 2018-03-27 04:37:23 -0700 | [diff] [blame] | 266 | local artifact_dir="$1" |
| 267 | |
Yun Peng | 70b29f4 | 2016-05-24 18:04:37 +0000 | [diff] [blame] | 268 | local release_name="$(get_release_name)" |
| 269 | local rc="$(get_release_candidate)" |
Philipp Wollermann | 5fabb43 | 2018-03-27 04:37:23 -0700 | [diff] [blame] | 270 | |
Yun Peng | 70b29f4 | 2016-05-24 18:04:37 +0000 | [diff] [blame] | 271 | if [ -n "${release_name}" ]; then |
Yun Peng | 70b29f4 | 2016-05-24 18:04:37 +0000 | [diff] [blame] | 272 | local release_label="$(get_full_release_name)" |
Philipp Wollermann | 5fabb43 | 2018-03-27 04:37:23 -0700 | [diff] [blame] | 273 | local deb_pkg_name="${release_name}/bazel_${release_label}-linux-x86_64.deb" |
Damien Martin-Guillerez | 4fb378c | 2016-12-20 11:04:02 +0000 | [diff] [blame] | 274 | local deb_dsc_name="${release_name}/bazel_${release_label}.dsc" |
| 275 | local deb_tar_name="${release_name}/bazel_${release_label}.tar.gz" |
Philipp Wollermann | 5fabb43 | 2018-03-27 04:37:23 -0700 | [diff] [blame] | 276 | |
| 277 | pushd "${artifact_dir}" |
Yun Peng | 70b29f4 | 2016-05-24 18:04:37 +0000 | [diff] [blame] | 278 | if [ -n "${rc}" ]; then |
Philipp Wollermann | 5fabb43 | 2018-03-27 04:37:23 -0700 | [diff] [blame] | 279 | create_apt_repository testing "${deb_pkg_name}" "${deb_dsc_name}" |
Yun Peng | 70b29f4 | 2016-05-24 18:04:37 +0000 | [diff] [blame] | 280 | else |
Philipp Wollermann | 5fabb43 | 2018-03-27 04:37:23 -0700 | [diff] [blame] | 281 | create_apt_repository stable "${deb_pkg_name}" "${deb_dsc_name}" |
Yun Peng | 70b29f4 | 2016-05-24 18:04:37 +0000 | [diff] [blame] | 282 | fi |
Philipp Wollermann | 5fabb43 | 2018-03-27 04:37:23 -0700 | [diff] [blame] | 283 | popd |
Damien Martin-Guillerez | f7a3931 | 2015-08-17 08:32:09 +0000 | [diff] [blame] | 284 | fi |
| 285 | } |
| 286 | |
| 287 | # A wrapper around the release deployment methods. |
| 288 | function deploy_release() { |
Philipp Wollermann | 5fabb43 | 2018-03-27 04:37:23 -0700 | [diff] [blame] | 289 | local release_label="$(get_full_release_name)" |
| 290 | local release_name="$(get_release_name)" |
| 291 | |
| 292 | if [[ ! -d $1 ]]; then |
| 293 | echo "Usage: deploy_release ARTIFACT_DIR" |
| 294 | exit 1 |
| 295 | fi |
| 296 | artifact_dir="$1" |
| 297 | |
| 298 | if [[ -z $release_name ]]; then |
| 299 | echo "Could not get the release name - are you in a release branch directory?" |
| 300 | exit 1 |
| 301 | fi |
| 302 | |
| 303 | ensure_gpg_secret_key_imported |
| 304 | |
| 305 | rm -f "${artifact_dir}"/*.{sha256,sig} |
| 306 | for file in "${artifact_dir}"/*; do |
| 307 | (cd "${artifact_dir}" && sha256sum "$(basename "${file}")" > "${file}.sha256") |
| 308 | gpg --no-tty --detach-sign -u "${APT_GPG_KEY_ID}" "${file}" |
Damien Martin-Guillerez | f7a3931 | 2015-08-17 08:32:09 +0000 | [diff] [blame] | 309 | done |
Philipp Wollermann | 5fabb43 | 2018-03-27 04:37:23 -0700 | [diff] [blame] | 310 | |
| 311 | apt_working_dir="$(mktemp -d --tmpdir)" |
| 312 | echo "apt_working_dir = ${apt_working_dir}" |
| 313 | mkdir "${apt_working_dir}/${release_name}" |
| 314 | cp "${artifact_dir}/bazel_${release_label}-linux-x86_64.deb" "${apt_working_dir}/${release_name}" |
| 315 | cp "${artifact_dir}/bazel_${release_label}.dsc" "${apt_working_dir}/${release_name}" |
| 316 | cp "${artifact_dir}/bazel_${release_label}.tar.gz" "${apt_working_dir}/${release_name}" |
| 317 | release_to_apt "${apt_working_dir}" |
| 318 | |
| 319 | gcs_working_dir="$(mktemp -d --tmpdir)" |
| 320 | echo "gcs_working_dir = ${gcs_working_dir}" |
| 321 | cp "${artifact_dir}"/* "${gcs_working_dir}" |
| 322 | release_to_gcs "${gcs_working_dir}" |
| 323 | |
| 324 | github_working_dir="$(mktemp -d --tmpdir)" |
| 325 | echo "github_working_dir = ${github_working_dir}" |
| 326 | cp "${artifact_dir}"/* "${github_working_dir}" |
philwo | 2b59370 | 2018-04-20 04:49:20 -0700 | [diff] [blame] | 327 | rm -f "${github_working_dir}/bazel_${release_label}"*.{dsc,tar.gz}{,.sha256,.sig} |
Philipp Wollermann | 5fabb43 | 2018-03-27 04:37:23 -0700 | [diff] [blame] | 328 | release_to_github "${github_working_dir}" |
Damien Martin-Guillerez | f7a3931 | 2015-08-17 08:32:09 +0000 | [diff] [blame] | 329 | } |