2021-01-01 21:49:51 +03:00
|
|
|
# Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
2020-08-14 12:35:57 +03:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
|
|
|
parameters:
|
2021-10-13 15:55:20 +03:00
|
|
|
var_name: ""
|
2020-08-14 12:35:57 +03:00
|
|
|
|
|
|
|
steps:
|
|
|
|
- bash: |
|
|
|
|
set -euo pipefail
|
|
|
|
TMP=$(mktemp)
|
2021-10-13 15:55:20 +03:00
|
|
|
cat > "$TMP" <<'END'
|
|
|
|
PROJ_DIR="$PWD"
|
2020-12-16 14:18:41 +03:00
|
|
|
escape_slack() {
|
|
|
|
local r
|
|
|
|
r="$1"
|
|
|
|
r="${r//&/&}"
|
|
|
|
r="${r//>/>}"
|
|
|
|
r="${r//</<}"
|
|
|
|
echo "$r"
|
|
|
|
}
|
2020-08-14 12:35:57 +03:00
|
|
|
get_gh_auth_header() {
|
|
|
|
# Credentials are persisted in a different way on GCP and Azure nodes.
|
|
|
|
if header=$(git config 'http.https://github.com/digital-asset/daml.extraheader'); then
|
|
|
|
# On Azure nodes, the auth header is stored directly in the git
|
|
|
|
# config.
|
|
|
|
echo $header
|
|
|
|
else
|
|
|
|
# On GCP nodes, the credentials are stored as part of the remote
|
|
|
|
# url instead of as a separate header. The format is
|
|
|
|
# https://username:password@github.com/:user/:repo.git
|
|
|
|
echo "Authorization: basic $(git config remote.origin.url | grep -o '://.*:.*@' | cut -c4- | rev | cut -c2- | rev | tr -d '\n' | base64 -w0)"
|
|
|
|
fi
|
|
|
|
}
|
2020-12-10 12:08:28 +03:00
|
|
|
open_pr() {
|
|
|
|
local branch title
|
|
|
|
branch="$1"
|
|
|
|
title="$2"
|
|
|
|
git branch -D $branch || true
|
|
|
|
git checkout -b $branch
|
|
|
|
git -c user.name="Azure Pipelines DAML Build" \
|
|
|
|
-c user.email="support@digitalasset.com" \
|
|
|
|
commit \
|
|
|
|
-m "$(printf "$title\n\nCHANGELOG_BEGIN\nCHANGELOG_END\n")"
|
|
|
|
git push origin $branch:$branch
|
|
|
|
jq -n --arg title "$title" \
|
|
|
|
--arg branch "$branch" \
|
2020-12-27 16:19:07 +03:00
|
|
|
'{"title": $title, "head": $branch, "base": "main"}' \
|
2020-12-10 12:08:28 +03:00
|
|
|
| curl -H "Content-Type: application/json" \
|
|
|
|
-H "$(get_gh_auth_header)" \
|
|
|
|
--fail \
|
|
|
|
--silent \
|
|
|
|
--include \
|
|
|
|
--location \
|
|
|
|
-d @- \
|
|
|
|
https://api.github.com/repos/digital-asset/daml/pulls
|
|
|
|
}
|
2020-12-04 15:16:34 +03:00
|
|
|
user_slack_handle() {
|
|
|
|
local email sha
|
|
|
|
sha=$1
|
|
|
|
email=$(git log -n 1 --format=%ae $sha)
|
|
|
|
if cat ci/slack_user_ids | grep $email >/dev/null 2>&1; then
|
|
|
|
echo $(cat ci/slack_user_ids | grep $email | awk '{print $2}')
|
|
|
|
else
|
|
|
|
echo ""
|
|
|
|
fi
|
|
|
|
}
|
2020-08-17 14:42:35 +03:00
|
|
|
tell_slack() {
|
|
|
|
local message channel
|
|
|
|
message="$1"
|
|
|
|
channel=${2:-$(Slack.team-daml)}
|
|
|
|
jq -n --arg message "$message" '{"text": $message}' \
|
|
|
|
| curl -XPOST -i -H 'Content-Type: application/json' -d @- $channel
|
|
|
|
}
|
2020-10-08 19:37:14 +03:00
|
|
|
gcs() {
|
2020-10-11 20:07:22 +03:00
|
|
|
local args cleanup cmd cred key restore_trap ret
|
|
|
|
ret=1
|
2020-09-14 21:38:31 +03:00
|
|
|
|
|
|
|
cred="$1"
|
2020-10-08 19:37:14 +03:00
|
|
|
cmd="$2"
|
|
|
|
args=(${@:3})
|
2020-09-14 21:38:31 +03:00
|
|
|
|
|
|
|
key=$(mktemp)
|
|
|
|
# There may already be a trap; this will save it
|
|
|
|
restore_trap=$(trap -p EXIT)
|
2021-03-08 10:56:33 +03:00
|
|
|
config_dir=$(mktemp -d)
|
|
|
|
cleanup="rm -rf $key $config_dir"
|
|
|
|
trap "$cleanup; $restore_trap" EXIT
|
2020-09-14 21:38:31 +03:00
|
|
|
echo "$cred" > $key
|
2021-03-08 10:56:33 +03:00
|
|
|
export CLOUDSDK_CONFIG="$config_dir"
|
2020-09-14 21:38:31 +03:00
|
|
|
gcloud auth activate-service-account --key-file=$key
|
|
|
|
|
2020-10-08 19:37:14 +03:00
|
|
|
BOTO_CONFIG=/dev/null gsutil $cmd "${args[@]}"
|
2020-10-11 20:07:22 +03:00
|
|
|
ret=$?
|
2020-09-14 21:38:31 +03:00
|
|
|
eval "$cleanup"
|
|
|
|
trap - EXIT
|
|
|
|
eval "$restore_trap"
|
2020-10-11 20:07:22 +03:00
|
|
|
return $ret
|
2020-09-14 21:38:31 +03:00
|
|
|
}
|
2020-10-01 22:01:42 +03:00
|
|
|
gpg_verify() {
|
|
|
|
local key gpg_dir signature_file res
|
|
|
|
signature_file=$1
|
|
|
|
key=$(mktemp)
|
|
|
|
cat > $key <<PUB_KEY
|
|
|
|
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
|
|
|
|
|
|
|
mQENBFzdsasBCADO+ZcfZQATP6ceTh4WfXiL2Z2tetvUZGfTaEs/UfBoJPmQ53bN
|
|
|
|
90MxudKhgB2mi8DuifYnHfLCvkxSgzfhj2IogV1S+Fa2x99Y819GausJoYfK9gwc
|
|
|
|
8YWKEkM81F15jA5UWJTsssKNxUddr/sxJIHIFfqGRQ0e6YeAcc5bOAogBE8UrmxE
|
|
|
|
uGfOt9/MvLpDewjDE+2lQOFi9RZuy7S8RMJLTiq2JWbO5yI50oFKeMQy/AJPmV7y
|
|
|
|
qAyYUIeZZxvrYeBWi5JDsZ2HOSJPqV7ttD2MvkyXcJCW/Xf8FcleAoWJU09RwVww
|
|
|
|
BhZSDz+9mipwZBHENILMuVyEygG5A+vc/YptABEBAAG0N0RpZ2l0YWwgQXNzZXQg
|
|
|
|
SG9sZGluZ3MsIExMQyA8c2V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as36BxMNvoNywMHHNMUQUCYHxZ3AUJB2EPMQAKCRDoNywMHHNMUYXRB/0b
|
|
|
|
Ln55mfnhJUFwaL49Le5I74EoL4vCAya6aDDVx/C7PJlVfr+cXZi9gNJn9RTAjCz3
|
|
|
|
4yQeg3AFhqvTK/bEH7RvAfqeUf8TqPjI/qDacSFDhZjdsg3GMDolXp0oubp9mN+Y
|
|
|
|
JFowLzulJ7DXFVyICozuWeixcjtKzlePX0GW80kcPzXCNwukcMrwCf45+OzF6YMb
|
|
|
|
yA2FyBmjjgAlHKM/oUapVoD2hmO3ptC5CAkfslxrsIUAfoStez9MrGoX1JOCu4qm
|
|
|
|
aODLV3Mlty4HhdtO2o+Akh6ay5fnrXQ5r2kGa1ICrfoFFKs7oWpSDbsTsgQKexFC
|
|
|
|
rLmmBKjG6RQfWJyVSUc8
|
|
|
|
=pVlb
|
2020-10-01 22:01:42 +03:00
|
|
|
-----END PGP PUBLIC KEY BLOCK-----
|
|
|
|
PUB_KEY
|
|
|
|
gpg_dir=$(mktemp -d)
|
|
|
|
GNUPGHOME=$gpg_dir gpg --no-tty --quiet --import $key
|
|
|
|
GNUPGHOME=$gpg_dir gpg --no-tty --quiet --command-fd 0 --edit-key 4911A8DFE976ACDFA07130DBE8372C0C1C734C51 << CMD
|
|
|
|
trust
|
|
|
|
4
|
|
|
|
quit
|
|
|
|
CMD
|
|
|
|
GNUPGHOME=$gpg_dir gpg --verify $signature_file
|
|
|
|
res=$?
|
|
|
|
rm -rf $gpg_dir $key
|
|
|
|
return $res
|
|
|
|
}
|
2021-02-09 13:42:34 +03:00
|
|
|
setvar() {
|
|
|
|
echo "Setting '$1' to '$2'"
|
|
|
|
echo "##vso[task.setvariable variable=$1;isOutput=true]$2"
|
|
|
|
}
|
2021-10-07 15:46:55 +03:00
|
|
|
next_in_rotation() {
|
|
|
|
awk '/^[^#]/ {print $0}' "$PROJ_DIR/release/rotation" | head -n 1
|
|
|
|
}
|
|
|
|
next_in_rotation_slack() {
|
|
|
|
next_in_rotation | awk '{print $1}'
|
|
|
|
}
|
|
|
|
next_in_rotation_github() {
|
|
|
|
next_in_rotation | awk '{print $2}'
|
|
|
|
}
|
2021-02-09 13:42:34 +03:00
|
|
|
|
2020-08-14 12:35:57 +03:00
|
|
|
END
|
|
|
|
echo "##vso[task.setvariable variable=${{parameters.var_name}}]$TMP"
|
2020-10-05 18:31:11 +03:00
|
|
|
displayName: install Bash lib
|
2021-03-24 21:38:41 +03:00
|
|
|
condition: always()
|