blob: 3b9093c72c5fd808e96b1958a92717a963049e99 [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
Ikko Ashimine31756f12021-08-23 10:41:44 -070019# Main deploy functions for the continuous build system
Damien Martin-Guillerezf7a39312015-08-17 08:32:09 +000020# 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
fwe1f52e9a2021-05-31 08:58:10 -070092 if [ "$(is_rolling_release)" -eq 1 ]; then
93 echo "No emails for rolling releases"
94 return 0
95 fi
96
Damien Martin-Guillerezf7a39312015-08-17 08:32:09 +000097 local release_name=$(get_release_name)
98 local rc=$(get_release_candidate)
99 local args=(
100 "%release_name%" "${release_name}"
101 "%rc%" "${rc}"
Damien Martin-Guillerezacbcbc22016-12-20 07:40:42 +0000102 "%relnotes%" "# $(get_full_release_notes)"
Damien Martin-Guillerezf7a39312015-08-17 08:32:09 +0000103 )
104 if [ -n "${rc}" ]; then
105 args+=(
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700106 "%url%" "$(generate_from_template "${RELEASE_CANDIDATE_URL}" "${args[@]}")"
Damien Martin-Guillerezf7a39312015-08-17 08:32:09 +0000107 )
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700108 generate_from_template \
Yun Peng123f2b92020-02-12 04:34:00 -0800109 "$(cat "${BUILD_SCRIPT_DIR}/rc_email.txt")" \
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700110 "${args[@]}"
Damien Martin-Guillerezf7a39312015-08-17 08:32:09 +0000111 elif [ -n "${release_name}" ]; then
112 args+=(
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700113 "%url%" "$(generate_from_template "${RELEASE_URL}" "${args[@]}")"
Damien Martin-Guillerezf7a39312015-08-17 08:32:09 +0000114 )
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700115 generate_from_template \
Yun Peng123f2b92020-02-12 04:34:00 -0800116 "$(cat "${BUILD_SCRIPT_DIR}/release_email.txt")" "${args[@]}"
Damien Martin-Guillerezf7a39312015-08-17 08:32:09 +0000117 fi
118}
119
dmarting5e576632017-07-24 19:01:08 +0200120function get_release_page() {
Damien Martin-Guillerezb6e29ca2017-07-26 16:06:44 +0200121 echo "# $(get_full_release_notes)"'
Damien Martin-Guillerezbf2e4ee2016-07-06 10:04:34 +0000122
123_Notice_: Bazel installers contain binaries licensed under the GPLv2 with
124Classpath exception. Those installers should always be redistributed along with
Damien Martin-Guillerez671045b2016-10-11 14:17:28 +0000125the source code.
126
Philipp Wollermann95048272017-03-17 15:11:58 +0000127Some versions of Bazel contain a bundled version of OpenJDK. The license of the
128bundled OpenJDK and other open-source components can be displayed by running
129the command `bazel license`. The vendor and version information of the bundled
130OpenJDK can be displayed by running the command `bazel info java-runtime`.
131The binaries and source-code of the bundled OpenJDK can be
dmartinge17f8902017-07-27 13:55:10 +0200132[downloaded from our mirror server](https://mirror.bazel.build/openjdk/index.html).
Philipp Wollermann95048272017-03-17 15:11:58 +0000133
Damien Martin-Guillerez671045b2016-10-11 14:17:28 +0000134_Security_: All our binaries are signed with our
Klaus Aehlig552cf562019-10-11 04:20:41 -0700135[public key](https://bazel.build/bazel-release.pub.gpg) 3D5919B448457EE0.
Damien Martin-Guillerez24795d42017-06-27 11:01:29 +0200136'
dmarting5e576632017-07-24 19:01:08 +0200137}
Damien Martin-Guillerezbf2e4ee2016-07-06 10:04:34 +0000138
dmarting5e576632017-07-24 19:01:08 +0200139# Deploy a github release using a third party tool:
140# https://github.com/c4milo/github-release
141# This methods expects the following arguments:
142# $1..$n files generated by package_build (should not contains the README file)
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700143# Please set GITHUB_TOKEN to talk to the Github API.
dmarting5e576632017-07-24 19:01:08 +0200144function release_to_github() {
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700145 local artifact_dir="$1"
146
dmarting5e576632017-07-24 19:01:08 +0200147 local release_name=$(get_release_name)
148 local rc=$(get_release_candidate)
dmarting5e576632017-07-24 19:01:08 +0200149
Damien Martin-Guillerezf7a39312015-08-17 08:32:09 +0000150 if [ -n "${release_name}" ] && [ -z "${rc}" ]; then
philwob8d0e1b2019-01-17 04:12:08 -0800151 local github_token="$(gsutil cat gs://bazel-trusted-encrypted-secrets/github-trusted-token.enc | \
152 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 -0700153
fwe1f52e9a2021-05-31 08:58:10 -0700154 if [ "$(is_rolling_release)" -eq 1 ]; then
fwe4ef9c562021-06-01 02:48:55 -0700155 GITHUB_TOKEN="${github_token}" github-release -prerelease "bazelbuild/bazel" "${release_name}" "" "$(get_release_page)" "${artifact_dir}/*"
fwe1f52e9a2021-05-31 08:58:10 -0700156 else
fwe4ef9c562021-06-01 02:48:55 -0700157 GITHUB_TOKEN="${github_token}" github-release "bazelbuild/bazel" "${release_name}" "" "$(get_release_page)" "${artifact_dir}/*"
fwe1f52e9a2021-05-31 08:58:10 -0700158 fi
Damien Martin-Guillerezf7a39312015-08-17 08:32:09 +0000159 fi
160}
161
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700162# Creates an index of the files contained in folder $1 in Markdown format.
Damien Martin-Guillerezf7a39312015-08-17 08:32:09 +0000163function create_index_md() {
dmarting5e576632017-07-24 19:01:08 +0200164 # First, add the release notes
165 get_release_page
Damien Martin-Guillerezf7a39312015-08-17 08:32:09 +0000166 # Then, add the list of files
167 echo
168 echo "## Index of files"
169 echo
170 for f in $1/*.sha256; do # just list the sha256 ones
171 local filename=$(basename $f .sha256);
Damien Martin-Guillerez671045b2016-10-11 14:17:28 +0000172 echo " - [${filename}](${filename}) [[SHA-256](${filename}.sha256)] [[SIG](${filename}.sig)]"
Damien Martin-Guillerezf7a39312015-08-17 08:32:09 +0000173 done
174}
175
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700176# Creates an index of the files contained in folder $1 in HTML format.
Damien Martin-Guillerezf7a39312015-08-17 08:32:09 +0000177function create_index_html() {
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700178 create_index_md "${@}" | pandoc -f markdown -t html
Yun Peng70b29f42016-05-24 18:04:37 +0000179}
180
Damien Martin-Guillerezf7a39312015-08-17 08:32:09 +0000181# Deploy a release candidate to Google Cloud Storage.
182# It requires to have gsutil installed. You can force the path to gsutil
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700183# by setting the GSUTIL environment variable.
Damien Martin-Guillerezf7a39312015-08-17 08:32:09 +0000184# This methods expects the following arguments:
185# $1..$n files generated by package_build
186function release_to_gcs() {
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700187 local artifact_dir="$1"
188
Yun Peng70b29f42016-05-24 18:04:37 +0000189 local release_name="$(get_release_name)"
190 local rc="$(get_release_candidate)"
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700191
dmartingebe36f22017-03-29 12:25:01 +0000192 if [ -n "${release_name}" ]; then
dmartingc58ba092017-05-04 12:38:16 +0200193 local release_path="${release_name}/release"
fwe1f52e9a2021-05-31 08:58:10 -0700194 if [ "$(is_rolling_release)" -eq 1 ]; then
195 # Store rolling releases and their RCs in the same directory (for simplicity)
196 release_path="$(get_lts_name)/rolling/$(get_full_release_name)"
197 elif [ -n "${rc}" ]; then
dmartingebe36f22017-03-29 12:25:01 +0000198 release_path="${release_name}/rc${rc}"
199 fi
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700200 create_index_html "${artifact_dir}" > "${artifact_dir}/index.html"
philwo3bbf9b9d2019-04-17 07:05:01 -0700201 gsutil -m cp "${artifact_dir}/**" "gs://bazel/${release_path}"
Yun Peng70b29f42016-05-24 18:04:37 +0000202 fi
203}
204
Yun Peng3d8ae222016-10-11 13:02:42 +0000205function ensure_gpg_secret_key_imported() {
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700206 if ! gpg --list-secret-keys | grep "${APT_GPG_KEY_ID}" > /dev/null; then
207 keyfile=$(mktemp --tmpdir)
208 chmod 0600 "${keyfile}"
philwoead58472019-05-10 08:23:25 -0700209 gsutil cat "gs://bazel-trusted-encrypted-secrets/release-key.gpg.enc" | \
philwo8ab09072018-04-25 12:57:20 -0700210 gcloud kms decrypt --location "global" --keyring "buildkite" --key "bazel-release-key" --ciphertext-file "-" --plaintext-file "${keyfile}"
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700211 gpg --allow-secret-key-import --import "${keyfile}"
212 rm -f "${keyfile}"
213 fi
214
Yun Peng2d1d4922016-11-15 13:33:47 +0000215 # Make sure we use stronger digest algorithm。
216 # We use reprepro to generate the debian repository,
217 # but there's no way to pass flags to gpg using reprepro, so writting it into
218 # ~/.gnupg/gpg.conf
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700219 if ! grep "digest-algo sha256" ~/.gnupg/gpg.conf > /dev/null; then
220 echo "digest-algo sha256" >> ~/.gnupg/gpg.conf
221 fi
Yun Peng3d8ae222016-10-11 13:02:42 +0000222}
223
Yun Peng31627052019-11-21 04:46:11 -0800224# Generate new content of Release file
225function print_new_release_content() {
226 local distribution="$1"
227 # Print the headers of the original Release file
228 cat <<EOF
229Origin: Bazel Authors
230Label: Bazel
231Codename: $1
232Date: $(date -u "+%a, %d %b %Y %H:%M:%S UTC")
233Architectures: amd64
234Components: jdk1.8
235Description: Bazel APT Repository
236EOF
237 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")
238 # Re-generate hashes for all metadata fiels
239 echo MD5Sum:
240 for file in ${metadata_files[*]}; do
241 path="dists/${distribution}/$file"
242 echo "" "$(md5sum ${path} | cut -d " " -f1)" "$(ls -l ${path} | cut -d " " -f5)" "$file"
243 done
244 echo SHA1:
245 for file in ${metadata_files[*]}; do
246 path="dists/${distribution}/$file"
247 echo "" "$(sha1sum ${path} | cut -d " " -f1)" "$(ls -l ${path} | cut -d " " -f5)" "$file"
248 done
249 echo SHA256:
250 for file in ${metadata_files[*]}; do
251 path="dists/${distribution}/$file"
252 echo "" "$(sha256sum ${path} | cut -d " " -f1)" "$(ls -l ${path} | cut -d " " -f5)" "$file"
253 done
254}
255
256# Merge metadata with previous distribution
257function merge_previous_dists() {
258 local distribution="$1"
Yun Pengdb0e32c2019-12-02 06:13:48 -0800259 # Download the metadata info from previous distribution
Yun Peng31627052019-11-21 04:46:11 -0800260 mkdir -p previous
261 gsutil -m cp -r "gs://bazel-apt/dists" "./previous"
262
263 # Merge Packages and Packages.gz file
264 cat "previous/dists/${distribution}/jdk1.8/binary-amd64/Packages" >> "dists/${distribution}/jdk1.8/binary-amd64/Packages"
265 gzip -9c "dists/${distribution}/jdk1.8/binary-amd64/Packages" > "dists/${distribution}/jdk1.8/binary-amd64/Packages.gz"
266
267 # Merge Sources.gz file
268 gunzip "previous/dists/${distribution}/jdk1.8/source/Sources.gz"
269 gunzip "dists/${distribution}/jdk1.8/source/Sources.gz"
270 cat "previous/dists/${distribution}/jdk1.8/source/Sources" >> "dists/${distribution}/jdk1.8/source/Sources"
271 gzip -9c "dists/${distribution}/jdk1.8/source/Sources" > "dists/${distribution}/jdk1.8/source/Sources.gz"
272 rm -f "dists/${distribution}/jdk1.8/source/Sources"
273
274 # Update Release file
275 print_new_release_content "${distribution}" > "dists/${distribution}/Release.new"
276 mv "dists/${distribution}/Release.new" "dists/${distribution}/Release"
277
278 # Generate new signatures for Release file
Yun Pengdb0e32c2019-12-02 06:13:48 -0800279 rm -f "dists/${distribution}/InRelease" "dists/${distribution}/Release.gpg"
Yun Peng63f0b362020-01-28 07:18:18 -0800280 gpg --output "dists/${distribution}/InRelease" --clearsign "dists/${distribution}/Release"
Yun Pengdb0e32c2019-12-02 06:13:48 -0800281 gpg --output "dists/${distribution}/Release.gpg" --detach-sign "dists/${distribution}/Release"
Yun Peng31627052019-11-21 04:46:11 -0800282}
283
284# Create a debian package with version in package name and add it to the repo
285function add_versioned_deb_pkg() {
286 local distribution="$1"
287 local deb_pkg_name="$2"
288 # Extract the original package
289 mkdir -p deb-old
290 dpkg-deb -R "${deb_pkg_name}" deb-old
291
292 # Get bazel version
293 bazel_version=$(grep "Version:" deb-old/DEBIAN/control | cut -d " " -f2)
294 bazel_version=${bazel_version/\~/}
295
296 # Generate new control file
297 mkdir -p deb-new/DEBIAN
298 sed "s/Package:\ bazel/Package:\ bazel-${bazel_version}/g" "deb-old/DEBIAN/control" > "deb-new/DEBIAN/control"
299
300 # Rename the actual Bazel binary to bazel-${bazel_version}
301 mkdir -p deb-new/usr/bin
302 cp "deb-old/usr/bin/bazel-real" "deb-new/usr/bin/bazel-${bazel_version}"
303
304 # Re-pack the debian package and add it to the repo
305 versioned_deb_pkg_name="bazel-${bazel_version}-versioned-package-amd64.deb"
306 chmod -R 0755 deb-new
307 dpkg-deb -b deb-new "${versioned_deb_pkg_name}"
308 reprepro -C jdk1.8 includedeb "${distribution}" "${versioned_deb_pkg_name}"
309}
310
Yun Peng70b29f42016-05-24 18:04:37 +0000311function create_apt_repository() {
312 mkdir conf
313 cat > conf/distributions <<EOF
314Origin: Bazel Authors
315Label: Bazel
316Codename: stable
Yun Peng55e042a2016-07-26 13:36:42 +0000317Architectures: amd64 source
Damien Martin-Guillerezc616acc2017-06-27 10:49:01 +0200318Components: jdk1.8
Yun Peng70b29f42016-05-24 18:04:37 +0000319Description: Bazel APT Repository
320DebOverride: override.stable
321DscOverride: override.stable
322SignWith: ${APT_GPG_KEY_ID}
323
324Origin: Bazel Authors
325Label: Bazel
326Codename: testing
Yun Peng55e042a2016-07-26 13:36:42 +0000327Architectures: amd64 source
Damien Martin-Guillerezc616acc2017-06-27 10:49:01 +0200328Components: jdk1.8
Yun Peng70b29f42016-05-24 18:04:37 +0000329Description: Bazel APT Repository
330DebOverride: override.testing
331DscOverride: override.testing
332SignWith: ${APT_GPG_KEY_ID}
333EOF
334
335 cat > conf/options <<EOF
336verbose
337ask-passphrase
338basedir .
339EOF
340
Damien Martin-Guillerez4fb378c2016-12-20 11:04:02 +0000341 # TODO(#2264): this is a quick workaround #2256, figure out a correct fix.
342 cat > conf/override.stable <<EOF
343bazel Section contrib/devel
344bazel Priority optional
345EOF
346 cat > conf/override.testing <<EOF
347bazel Section contrib/devel
348bazel Priority optional
349EOF
Yun Peng70b29f42016-05-24 18:04:37 +0000350
Yun Peng3d8ae222016-10-11 13:02:42 +0000351 ensure_gpg_secret_key_imported
Yun Peng70b29f42016-05-24 18:04:37 +0000352
353 local distribution="$1"
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700354 local deb_pkg_name="$2"
Damien Martin-Guillerezc616acc2017-06-27 10:49:01 +0200355 local deb_dsc_name="$3"
Yun Peng55e042a2016-07-26 13:36:42 +0000356
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700357 debsign -k "${APT_GPG_KEY_ID}" "${deb_dsc_name}"
Yun Peng55e042a2016-07-26 13:36:42 +0000358
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700359 reprepro -C jdk1.8 includedeb "${distribution}" "${deb_pkg_name}"
Yun Peng55e042a2016-07-26 13:36:42 +0000360 reprepro -C jdk1.8 includedsc "${distribution}" "${deb_dsc_name}"
Yun Peng70b29f42016-05-24 18:04:37 +0000361
Yun Peng31627052019-11-21 04:46:11 -0800362 add_versioned_deb_pkg "${distribution}" "${deb_pkg_name}"
363
364 merge_previous_dists "${distribution}"
365
philwo3bbf9b9d2019-04-17 07:05:01 -0700366 gsutil -m cp -r dists pool "gs://bazel-apt"
Yun Peng70b29f42016-05-24 18:04:37 +0000367}
368
369function release_to_apt() {
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700370 local artifact_dir="$1"
371
Yun Peng70b29f42016-05-24 18:04:37 +0000372 local release_name="$(get_release_name)"
373 local rc="$(get_release_candidate)"
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700374
Yun Peng70b29f42016-05-24 18:04:37 +0000375 if [ -n "${release_name}" ]; then
Yun Peng70b29f42016-05-24 18:04:37 +0000376 local release_label="$(get_full_release_name)"
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700377 local deb_pkg_name="${release_name}/bazel_${release_label}-linux-x86_64.deb"
Damien Martin-Guillerez4fb378c2016-12-20 11:04:02 +0000378 local deb_dsc_name="${release_name}/bazel_${release_label}.dsc"
379 local deb_tar_name="${release_name}/bazel_${release_label}.tar.gz"
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700380
381 pushd "${artifact_dir}"
Yun Peng70b29f42016-05-24 18:04:37 +0000382 if [ -n "${rc}" ]; then
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700383 create_apt_repository testing "${deb_pkg_name}" "${deb_dsc_name}"
Yun Peng70b29f42016-05-24 18:04:37 +0000384 else
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700385 create_apt_repository stable "${deb_pkg_name}" "${deb_dsc_name}"
Yun Peng70b29f42016-05-24 18:04:37 +0000386 fi
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700387 popd
Damien Martin-Guillerezf7a39312015-08-17 08:32:09 +0000388 fi
389}
390
391# A wrapper around the release deployment methods.
392function deploy_release() {
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700393 local release_label="$(get_full_release_name)"
394 local release_name="$(get_release_name)"
395
396 if [[ ! -d $1 ]]; then
397 echo "Usage: deploy_release ARTIFACT_DIR"
398 exit 1
399 fi
400 artifact_dir="$1"
401
402 if [[ -z $release_name ]]; then
403 echo "Could not get the release name - are you in a release branch directory?"
404 exit 1
405 fi
406
407 ensure_gpg_secret_key_imported
408
409 rm -f "${artifact_dir}"/*.{sha256,sig}
410 for file in "${artifact_dir}"/*; do
411 (cd "${artifact_dir}" && sha256sum "$(basename "${file}")" > "${file}.sha256")
412 gpg --no-tty --detach-sign -u "${APT_GPG_KEY_ID}" "${file}"
Damien Martin-Guillerezf7a39312015-08-17 08:32:09 +0000413 done
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700414
fwe1f52e9a2021-05-31 08:58:10 -0700415 if [ "$(is_rolling_release)" -eq 0 ]; then
416 apt_working_dir="$(mktemp -d --tmpdir)"
417 echo "apt_working_dir = ${apt_working_dir}"
418 mkdir "${apt_working_dir}/${release_name}"
419 cp "${artifact_dir}/bazel_${release_label}-linux-x86_64.deb" "${apt_working_dir}/${release_name}"
420 cp "${artifact_dir}/bazel_${release_label}.dsc" "${apt_working_dir}/${release_name}"
421 cp "${artifact_dir}/bazel_${release_label}.tar.gz" "${apt_working_dir}/${release_name}"
422 release_to_apt "${apt_working_dir}"
423 fi
424
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700425
426 gcs_working_dir="$(mktemp -d --tmpdir)"
427 echo "gcs_working_dir = ${gcs_working_dir}"
428 cp "${artifact_dir}"/* "${gcs_working_dir}"
429 release_to_gcs "${gcs_working_dir}"
430
431 github_working_dir="$(mktemp -d --tmpdir)"
432 echo "github_working_dir = ${github_working_dir}"
433 cp "${artifact_dir}"/* "${github_working_dir}"
philwo2b593702018-04-20 04:49:20 -0700434 rm -f "${github_working_dir}/bazel_${release_label}"*.{dsc,tar.gz}{,.sha256,.sig}
Philipp Wollermann5fabb432018-03-27 04:37:23 -0700435 release_to_github "${github_working_dir}"
Damien Martin-Guillerezf7a39312015-08-17 08:32:09 +0000436}
fwe1f52e9a2021-05-31 08:58:10 -0700437