blob: 6d9fec90e697ee8ada4edb7676eb3131010ec482 [file] [log] [blame]
Philipp Wollermanna5afe952016-06-21 14:58:09 +00001#!/bin/bash
Damien Martin-Guillerezf7a39312015-08-17 08:32:09 +00002
Damien Martin-Guillerezf88f4d82015-09-25 13:56:55 +00003# Copyright 2015 The Bazel Authors. All rights reserved.
Damien Martin-Guillerezf7a39312015-08-17 08:32:09 +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-Guillerezf7a39312015-08-17 08:32:09 +000019# 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
Yun Peng123f2b92020-02-12 04:34:00 -080027BUILD_SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
28source "$(dirname ${BUILD_SCRIPT_DIR})/release/common.sh"
29source "$(dirname ${BUILD_SCRIPT_DIR})/release/relnotes.sh"
Damien Martin-Guillerezf7a39312015-08-17 08:32:09 +000030
Philipp Wollermann5fabb432018-03-27 04:37:23 -070031if ! command -v gsutil &>/dev/null; then
32 echo "Required tool 'gsutil' not found. Please install it:"
33 echo "See https://cloud.google.com/sdk/downloads for instructions."
34 exit 1
35fi
36if ! command -v github-release &>/dev/null; then
37 echo "Required tool 'github-release' not found. Download it from here:"
38 echo "https://github.com/c4milo/github-release/releases"
39 echo "Just extract the archive and put the binary on your PATH."
40 exit 1
41fi
42if ! command -v debsign &>/dev/null; then
43 echo "Required tool 'debsign' not found. Please install it via apt-get:"
44 echo "apt-get install devscripts"
45 exit 1
46fi
47if ! command -v reprepro &>/dev/null; then
48 echo "Required tool 'reprepro' not found. Please install it via apt-get:"
49 echo "apt-get install reprepro"
50 exit 1
51fi
52if ! command -v gpg &>/dev/null; then
53 echo "Required tool 'gpg' not found. Please install it via apt-get:"
54 echo "apt-get install gnupg"
55 exit 1
56fi
57if ! command -v pandoc &>/dev/null; then
58 echo "Required tool 'pandoc' not found. Please install it via apt-get:"
59 echo "apt-get install pandoc"
60 exit 1
61fi
62# if ! command -v ssmtp &>/dev/null; then
63# echo "Required tool 'ssmtp' not found. Please install it via apt-get:"
64# echo "apt-get install ssmtp"
65# exit 1
66# fi
Damien Martin-Guillerezf7a39312015-08-17 08:32:09 +000067
philwoead58472019-05-10 08:23:25 -070068export APT_GPG_KEY_ID=$(gsutil cat gs://bazel-trusted-encrypted-secrets/release-key.gpg.id)
Klaus Aehlig736c46d2016-11-10 16:09:34 +000069
Damien Martin-Guillerezf7a39312015-08-17 08:32:09 +000070# Generate a string from a template and a list of substitutions.
71# The first parameter is the template name and each subsequent parameter
72# is taken as a couple: first is the string the substitute and the second
73# is the result of the substitution.
74function generate_from_template() {
75 local value="$1"
76 shift
77 while (( $# >= 2 )); do
78 value="${value//$1/$2}"
79 shift 2
80 done
81 echo "${value}"
82}
83
84# Generate the email for the release.
85# The first line of the output will be the recipient, the second line
86# the mail subjects and the subsequent lines the mail, its content.
87# If no planed release, then this function output will be empty.
88function generate_email() {
Philipp Wollermann5fabb432018-03-27 04:37:23 -070089 RELEASE_CANDIDATE_URL="https://releases.bazel.build/%release_name%/rc%rc%/index.html"
90 RELEASE_URL="https://github.com/bazelbuild/bazel/releases/tag/%release_name%"
91
Damien Martin-Guillerezf7a39312015-08-17 08:32:09 +000092 local release_name=$(get_release_name)
93 local rc=$(get_release_candidate)
94 local args=(
95 "%release_name%" "${release_name}"
96 "%rc%" "${rc}"
Damien Martin-Guillerezacbcbc22016-12-20 07:40:42 +000097 "%relnotes%" "# $(get_full_release_notes)"
Damien Martin-Guillerezf7a39312015-08-17 08:32:09 +000098 )
99 if [ -n "${rc}" ]; then
100 args+=(
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700101 "%url%" "$(generate_from_template "${RELEASE_CANDIDATE_URL}" "${args[@]}")"
Damien Martin-Guillerezf7a39312015-08-17 08:32:09 +0000102 )
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700103 generate_from_template \
Yun Peng123f2b92020-02-12 04:34:00 -0800104 "$(cat "${BUILD_SCRIPT_DIR}/rc_email.txt")" \
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700105 "${args[@]}"
Damien Martin-Guillerezf7a39312015-08-17 08:32:09 +0000106 elif [ -n "${release_name}" ]; then
107 args+=(
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700108 "%url%" "$(generate_from_template "${RELEASE_URL}" "${args[@]}")"
Damien Martin-Guillerezf7a39312015-08-17 08:32:09 +0000109 )
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700110 generate_from_template \
Yun Peng123f2b92020-02-12 04:34:00 -0800111 "$(cat "${BUILD_SCRIPT_DIR}/release_email.txt")" "${args[@]}"
Damien Martin-Guillerezf7a39312015-08-17 08:32:09 +0000112 fi
113}
114
dmarting5e576632017-07-24 19:01:08 +0200115function get_release_page() {
Damien Martin-Guillerezb6e29ca2017-07-26 16:06:44 +0200116 echo "# $(get_full_release_notes)"'
Damien Martin-Guillerezbf2e4ee2016-07-06 10:04:34 +0000117
118_Notice_: Bazel installers contain binaries licensed under the GPLv2 with
119Classpath exception. Those installers should always be redistributed along with
Damien Martin-Guillerez671045b2016-10-11 14:17:28 +0000120the source code.
121
Philipp Wollermann95048272017-03-17 15:11:58 +0000122Some versions of Bazel contain a bundled version of OpenJDK. The license of the
123bundled OpenJDK and other open-source components can be displayed by running
124the command `bazel license`. The vendor and version information of the bundled
125OpenJDK can be displayed by running the command `bazel info java-runtime`.
126The binaries and source-code of the bundled OpenJDK can be
dmartinge17f8902017-07-27 13:55:10 +0200127[downloaded from our mirror server](https://mirror.bazel.build/openjdk/index.html).
Philipp Wollermann95048272017-03-17 15:11:58 +0000128
Damien Martin-Guillerez671045b2016-10-11 14:17:28 +0000129_Security_: All our binaries are signed with our
Klaus Aehlig552cf562019-10-11 04:20:41 -0700130[public key](https://bazel.build/bazel-release.pub.gpg) 3D5919B448457EE0.
Damien Martin-Guillerez24795d42017-06-27 11:01:29 +0200131'
dmarting5e576632017-07-24 19:01:08 +0200132}
Damien Martin-Guillerezbf2e4ee2016-07-06 10:04:34 +0000133
dmarting5e576632017-07-24 19:01:08 +0200134# Deploy a github release using a third party tool:
135# https://github.com/c4milo/github-release
136# This methods expects the following arguments:
137# $1..$n files generated by package_build (should not contains the README file)
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700138# Please set GITHUB_TOKEN to talk to the Github API.
dmarting5e576632017-07-24 19:01:08 +0200139function release_to_github() {
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700140 local artifact_dir="$1"
141
dmarting5e576632017-07-24 19:01:08 +0200142 local release_name=$(get_release_name)
143 local rc=$(get_release_candidate)
dmarting5e576632017-07-24 19:01:08 +0200144
Damien Martin-Guillerezf7a39312015-08-17 08:32:09 +0000145 if [ -n "${release_name}" ] && [ -z "${rc}" ]; then
philwob8d0e1b2019-01-17 04:12:08 -0800146 local github_token="$(gsutil cat gs://bazel-trusted-encrypted-secrets/github-trusted-token.enc | \
147 gcloud kms decrypt --project bazel-public --location global --keyring buildkite --key github-trusted-token --ciphertext-file - --plaintext-file -)"
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700148
philwob8d0e1b2019-01-17 04:12:08 -0800149 GITHUB_TOKEN="${github_token}" github-release "bazelbuild/bazel" "${release_name}" "" "$(get_release_page)" "${artifact_dir}/*"
Damien Martin-Guillerezf7a39312015-08-17 08:32:09 +0000150 fi
151}
152
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700153# Creates an index of the files contained in folder $1 in Markdown format.
Damien Martin-Guillerezf7a39312015-08-17 08:32:09 +0000154function create_index_md() {
dmarting5e576632017-07-24 19:01:08 +0200155 # First, add the release notes
156 get_release_page
Damien Martin-Guillerezf7a39312015-08-17 08:32:09 +0000157 # Then, add the list of files
158 echo
159 echo "## Index of files"
160 echo
161 for f in $1/*.sha256; do # just list the sha256 ones
162 local filename=$(basename $f .sha256);
Damien Martin-Guillerez671045b2016-10-11 14:17:28 +0000163 echo " - [${filename}](${filename}) [[SHA-256](${filename}.sha256)] [[SIG](${filename}.sig)]"
Damien Martin-Guillerezf7a39312015-08-17 08:32:09 +0000164 done
165}
166
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700167# Creates an index of the files contained in folder $1 in HTML format.
Damien Martin-Guillerezf7a39312015-08-17 08:32:09 +0000168function create_index_html() {
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700169 create_index_md "${@}" | pandoc -f markdown -t html
Yun Peng70b29f42016-05-24 18:04:37 +0000170}
171
Damien Martin-Guillerezf7a39312015-08-17 08:32:09 +0000172# Deploy a release candidate to Google Cloud Storage.
173# It requires to have gsutil installed. You can force the path to gsutil
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700174# by setting the GSUTIL environment variable.
Damien Martin-Guillerezf7a39312015-08-17 08:32:09 +0000175# This methods expects the following arguments:
176# $1..$n files generated by package_build
177function release_to_gcs() {
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700178 local artifact_dir="$1"
179
Yun Peng70b29f42016-05-24 18:04:37 +0000180 local release_name="$(get_release_name)"
181 local rc="$(get_release_candidate)"
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700182
dmartingebe36f22017-03-29 12:25:01 +0000183 if [ -n "${release_name}" ]; then
dmartingc58ba092017-05-04 12:38:16 +0200184 local release_path="${release_name}/release"
dmartingebe36f22017-03-29 12:25:01 +0000185 if [ -n "${rc}" ]; then
186 release_path="${release_name}/rc${rc}"
187 fi
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700188 create_index_html "${artifact_dir}" > "${artifact_dir}/index.html"
philwo3bbf9b9d2019-04-17 07:05:01 -0700189 gsutil -m cp "${artifact_dir}/**" "gs://bazel/${release_path}"
Yun Peng70b29f42016-05-24 18:04:37 +0000190 fi
191}
192
Yun Peng3d8ae222016-10-11 13:02:42 +0000193function ensure_gpg_secret_key_imported() {
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700194 if ! gpg --list-secret-keys | grep "${APT_GPG_KEY_ID}" > /dev/null; then
195 keyfile=$(mktemp --tmpdir)
196 chmod 0600 "${keyfile}"
philwoead58472019-05-10 08:23:25 -0700197 gsutil cat "gs://bazel-trusted-encrypted-secrets/release-key.gpg.enc" | \
philwo8ab09072018-04-25 12:57:20 -0700198 gcloud kms decrypt --location "global" --keyring "buildkite" --key "bazel-release-key" --ciphertext-file "-" --plaintext-file "${keyfile}"
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700199 gpg --allow-secret-key-import --import "${keyfile}"
200 rm -f "${keyfile}"
201 fi
202
Yun Peng2d1d4922016-11-15 13:33:47 +0000203 # Make sure we use stronger digest algorithm。
204 # We use reprepro to generate the debian repository,
205 # but there's no way to pass flags to gpg using reprepro, so writting it into
206 # ~/.gnupg/gpg.conf
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700207 if ! grep "digest-algo sha256" ~/.gnupg/gpg.conf > /dev/null; then
208 echo "digest-algo sha256" >> ~/.gnupg/gpg.conf
209 fi
Yun Peng3d8ae222016-10-11 13:02:42 +0000210}
211
Yun Peng31627052019-11-21 04:46:11 -0800212# Generate new content of Release file
213function print_new_release_content() {
214 local distribution="$1"
215 # Print the headers of the original Release file
216 cat <<EOF
217Origin: Bazel Authors
218Label: Bazel
219Codename: $1
220Date: $(date -u "+%a, %d %b %Y %H:%M:%S UTC")
221Architectures: amd64
222Components: jdk1.8
223Description: Bazel APT Repository
224EOF
225 metadata_files=("jdk1.8/binary-amd64/Packages" "jdk1.8/binary-amd64/Packages.gz" "jdk1.8/binary-amd64/Release" "jdk1.8/source/Sources.gz" "jdk1.8/source/Release")
226 # Re-generate hashes for all metadata fiels
227 echo MD5Sum:
228 for file in ${metadata_files[*]}; do
229 path="dists/${distribution}/$file"
230 echo "" "$(md5sum ${path} | cut -d " " -f1)" "$(ls -l ${path} | cut -d " " -f5)" "$file"
231 done
232 echo SHA1:
233 for file in ${metadata_files[*]}; do
234 path="dists/${distribution}/$file"
235 echo "" "$(sha1sum ${path} | cut -d " " -f1)" "$(ls -l ${path} | cut -d " " -f5)" "$file"
236 done
237 echo SHA256:
238 for file in ${metadata_files[*]}; do
239 path="dists/${distribution}/$file"
240 echo "" "$(sha256sum ${path} | cut -d " " -f1)" "$(ls -l ${path} | cut -d " " -f5)" "$file"
241 done
242}
243
244# Merge metadata with previous distribution
245function merge_previous_dists() {
246 local distribution="$1"
Yun Pengdb0e32c2019-12-02 06:13:48 -0800247 # Download the metadata info from previous distribution
Yun Peng31627052019-11-21 04:46:11 -0800248 mkdir -p previous
249 gsutil -m cp -r "gs://bazel-apt/dists" "./previous"
250
251 # Merge Packages and Packages.gz file
252 cat "previous/dists/${distribution}/jdk1.8/binary-amd64/Packages" >> "dists/${distribution}/jdk1.8/binary-amd64/Packages"
253 gzip -9c "dists/${distribution}/jdk1.8/binary-amd64/Packages" > "dists/${distribution}/jdk1.8/binary-amd64/Packages.gz"
254
255 # Merge Sources.gz file
256 gunzip "previous/dists/${distribution}/jdk1.8/source/Sources.gz"
257 gunzip "dists/${distribution}/jdk1.8/source/Sources.gz"
258 cat "previous/dists/${distribution}/jdk1.8/source/Sources" >> "dists/${distribution}/jdk1.8/source/Sources"
259 gzip -9c "dists/${distribution}/jdk1.8/source/Sources" > "dists/${distribution}/jdk1.8/source/Sources.gz"
260 rm -f "dists/${distribution}/jdk1.8/source/Sources"
261
262 # Update Release file
263 print_new_release_content "${distribution}" > "dists/${distribution}/Release.new"
264 mv "dists/${distribution}/Release.new" "dists/${distribution}/Release"
265
266 # Generate new signatures for Release file
Yun Pengdb0e32c2019-12-02 06:13:48 -0800267 rm -f "dists/${distribution}/InRelease" "dists/${distribution}/Release.gpg"
Yun Peng63f0b362020-01-28 07:18:18 -0800268 gpg --output "dists/${distribution}/InRelease" --clearsign "dists/${distribution}/Release"
Yun Pengdb0e32c2019-12-02 06:13:48 -0800269 gpg --output "dists/${distribution}/Release.gpg" --detach-sign "dists/${distribution}/Release"
Yun Peng31627052019-11-21 04:46:11 -0800270}
271
272# Create a debian package with version in package name and add it to the repo
273function add_versioned_deb_pkg() {
274 local distribution="$1"
275 local deb_pkg_name="$2"
276 # Extract the original package
277 mkdir -p deb-old
278 dpkg-deb -R "${deb_pkg_name}" deb-old
279
280 # Get bazel version
281 bazel_version=$(grep "Version:" deb-old/DEBIAN/control | cut -d " " -f2)
282 bazel_version=${bazel_version/\~/}
283
284 # Generate new control file
285 mkdir -p deb-new/DEBIAN
286 sed "s/Package:\ bazel/Package:\ bazel-${bazel_version}/g" "deb-old/DEBIAN/control" > "deb-new/DEBIAN/control"
287
288 # Rename the actual Bazel binary to bazel-${bazel_version}
289 mkdir -p deb-new/usr/bin
290 cp "deb-old/usr/bin/bazel-real" "deb-new/usr/bin/bazel-${bazel_version}"
291
292 # Re-pack the debian package and add it to the repo
293 versioned_deb_pkg_name="bazel-${bazel_version}-versioned-package-amd64.deb"
294 chmod -R 0755 deb-new
295 dpkg-deb -b deb-new "${versioned_deb_pkg_name}"
296 reprepro -C jdk1.8 includedeb "${distribution}" "${versioned_deb_pkg_name}"
297}
298
Yun Peng70b29f42016-05-24 18:04:37 +0000299function create_apt_repository() {
300 mkdir conf
301 cat > conf/distributions <<EOF
302Origin: Bazel Authors
303Label: Bazel
304Codename: stable
Yun Peng55e042a2016-07-26 13:36:42 +0000305Architectures: amd64 source
Damien Martin-Guillerezc616acc2017-06-27 10:49:01 +0200306Components: jdk1.8
Yun Peng70b29f42016-05-24 18:04:37 +0000307Description: Bazel APT Repository
308DebOverride: override.stable
309DscOverride: override.stable
310SignWith: ${APT_GPG_KEY_ID}
311
312Origin: Bazel Authors
313Label: Bazel
314Codename: testing
Yun Peng55e042a2016-07-26 13:36:42 +0000315Architectures: amd64 source
Damien Martin-Guillerezc616acc2017-06-27 10:49:01 +0200316Components: jdk1.8
Yun Peng70b29f42016-05-24 18:04:37 +0000317Description: Bazel APT Repository
318DebOverride: override.testing
319DscOverride: override.testing
320SignWith: ${APT_GPG_KEY_ID}
321EOF
322
323 cat > conf/options <<EOF
324verbose
325ask-passphrase
326basedir .
327EOF
328
Damien Martin-Guillerez4fb378c2016-12-20 11:04:02 +0000329 # TODO(#2264): this is a quick workaround #2256, figure out a correct fix.
330 cat > conf/override.stable <<EOF
331bazel Section contrib/devel
332bazel Priority optional
333EOF
334 cat > conf/override.testing <<EOF
335bazel Section contrib/devel
336bazel Priority optional
337EOF
Yun Peng70b29f42016-05-24 18:04:37 +0000338
Yun Peng3d8ae222016-10-11 13:02:42 +0000339 ensure_gpg_secret_key_imported
Yun Peng70b29f42016-05-24 18:04:37 +0000340
341 local distribution="$1"
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700342 local deb_pkg_name="$2"
Damien Martin-Guillerezc616acc2017-06-27 10:49:01 +0200343 local deb_dsc_name="$3"
Yun Peng55e042a2016-07-26 13:36:42 +0000344
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700345 debsign -k "${APT_GPG_KEY_ID}" "${deb_dsc_name}"
Yun Peng55e042a2016-07-26 13:36:42 +0000346
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700347 reprepro -C jdk1.8 includedeb "${distribution}" "${deb_pkg_name}"
Yun Peng55e042a2016-07-26 13:36:42 +0000348 reprepro -C jdk1.8 includedsc "${distribution}" "${deb_dsc_name}"
Yun Peng70b29f42016-05-24 18:04:37 +0000349
Yun Peng31627052019-11-21 04:46:11 -0800350 add_versioned_deb_pkg "${distribution}" "${deb_pkg_name}"
351
352 merge_previous_dists "${distribution}"
353
philwo3bbf9b9d2019-04-17 07:05:01 -0700354 gsutil -m cp -r dists pool "gs://bazel-apt"
Yun Peng70b29f42016-05-24 18:04:37 +0000355}
356
357function release_to_apt() {
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700358 local artifact_dir="$1"
359
Yun Peng70b29f42016-05-24 18:04:37 +0000360 local release_name="$(get_release_name)"
361 local rc="$(get_release_candidate)"
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700362
Yun Peng70b29f42016-05-24 18:04:37 +0000363 if [ -n "${release_name}" ]; then
Yun Peng70b29f42016-05-24 18:04:37 +0000364 local release_label="$(get_full_release_name)"
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700365 local deb_pkg_name="${release_name}/bazel_${release_label}-linux-x86_64.deb"
Damien Martin-Guillerez4fb378c2016-12-20 11:04:02 +0000366 local deb_dsc_name="${release_name}/bazel_${release_label}.dsc"
367 local deb_tar_name="${release_name}/bazel_${release_label}.tar.gz"
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700368
369 pushd "${artifact_dir}"
Yun Peng70b29f42016-05-24 18:04:37 +0000370 if [ -n "${rc}" ]; then
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700371 create_apt_repository testing "${deb_pkg_name}" "${deb_dsc_name}"
Yun Peng70b29f42016-05-24 18:04:37 +0000372 else
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700373 create_apt_repository stable "${deb_pkg_name}" "${deb_dsc_name}"
Yun Peng70b29f42016-05-24 18:04:37 +0000374 fi
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700375 popd
Damien Martin-Guillerezf7a39312015-08-17 08:32:09 +0000376 fi
377}
378
379# A wrapper around the release deployment methods.
380function deploy_release() {
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700381 local release_label="$(get_full_release_name)"
382 local release_name="$(get_release_name)"
383
384 if [[ ! -d $1 ]]; then
385 echo "Usage: deploy_release ARTIFACT_DIR"
386 exit 1
387 fi
388 artifact_dir="$1"
389
390 if [[ -z $release_name ]]; then
391 echo "Could not get the release name - are you in a release branch directory?"
392 exit 1
393 fi
394
395 ensure_gpg_secret_key_imported
396
397 rm -f "${artifact_dir}"/*.{sha256,sig}
398 for file in "${artifact_dir}"/*; do
399 (cd "${artifact_dir}" && sha256sum "$(basename "${file}")" > "${file}.sha256")
400 gpg --no-tty --detach-sign -u "${APT_GPG_KEY_ID}" "${file}"
Damien Martin-Guillerezf7a39312015-08-17 08:32:09 +0000401 done
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700402
403 apt_working_dir="$(mktemp -d --tmpdir)"
404 echo "apt_working_dir = ${apt_working_dir}"
405 mkdir "${apt_working_dir}/${release_name}"
406 cp "${artifact_dir}/bazel_${release_label}-linux-x86_64.deb" "${apt_working_dir}/${release_name}"
407 cp "${artifact_dir}/bazel_${release_label}.dsc" "${apt_working_dir}/${release_name}"
408 cp "${artifact_dir}/bazel_${release_label}.tar.gz" "${apt_working_dir}/${release_name}"
409 release_to_apt "${apt_working_dir}"
410
411 gcs_working_dir="$(mktemp -d --tmpdir)"
412 echo "gcs_working_dir = ${gcs_working_dir}"
413 cp "${artifact_dir}"/* "${gcs_working_dir}"
414 release_to_gcs "${gcs_working_dir}"
415
416 github_working_dir="$(mktemp -d --tmpdir)"
417 echo "github_working_dir = ${github_working_dir}"
418 cp "${artifact_dir}"/* "${github_working_dir}"
philwo2b593702018-04-20 04:49:20 -0700419 rm -f "${github_working_dir}/bazel_${release_label}"*.{dsc,tar.gz}{,.sha256,.sig}
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700420 release_to_github "${github_working_dir}"
Damien Martin-Guillerezf7a39312015-08-17 08:32:09 +0000421}