2021-01-01 21:49:51 +03:00
# Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
2020-07-24 19:40:11 +03:00
# SPDX-License-Identifier: Apache-2.0
pr : none
trigger : none
schedules :
- cron : "0 6 * * Wed"
displayName : weekly snapshot
branches :
include :
2020-12-27 16:19:07 +03:00
- main
2020-07-24 19:40:11 +03:00
always : true
jobs :
- job : open_release_pr
timeoutInMinutes : 60
pool :
2021-01-05 12:39:59 +03:00
vmImage : ubuntu-18.04
2020-07-24 19:40:11 +03:00
steps :
- checkout : self
persistCredentials : true
2020-08-14 12:35:57 +03:00
- template : ../bash-lib.yml
parameters :
var_name : bash_lib
2020-07-24 19:40:11 +03:00
- bash : |
set -euo pipefail
2020-08-14 12:35:57 +03:00
source "$(bash_lib)"
AUTH="$(get_gh_auth_header)"
2020-08-05 19:58:56 +03:00
BASE_SHA=$(git rev-parse HEAD)
az extension add --name azure-devops
echo "$(System.AccessToken)" | az devops login --org "https://dev.azure.com/digitalasset"
reset() {
git checkout -f $BASE_SHA
git reset --hard
}
open_pr() {
local branch title body out pr_number
branch=$1
title="$2"
body="$3"
2020-08-12 11:50:28 +03:00
out="${4:-}"
2020-08-05 19:58:56 +03:00
git branch -D $branch || true
git checkout -b $branch
git add .
git -c user.name="Azure Pipelines DAML Build" \
-c user.email="support@digitalasset.com" \
commit \
-m "$(printf "$title\n\n$body\n\nCHANGELOG_BEGIN\nCHANGELOG_END\n")"
git push origin $branch:$branch
pr_number=$(jq -n \
--arg branch "$branch" \
--arg title "$title" \
--arg body "$(printf "$body")" \
2020-12-27 16:19:07 +03:00
'{"title": $title, "head": $branch, "base": "main", "body": $body}' \
2020-08-05 19:58:56 +03:00
| curl -H "Content-Type: application/json" \
-H "$AUTH" \
--silent \
--location \
-d @- \
https://api.github.com/repos/digital-asset/daml/pulls \
| jq '.number')
az pipelines build queue \
--branch $branch \
2021-01-13 14:30:17 +03:00
--definition-name "PRs" \
2020-08-05 19:58:56 +03:00
--org "https://dev.azure.com/digitalasset" \
--project daml
if [ -n "$out" ]; then
echo $pr_number > $out
fi
}
assign_and_label() {
local pr_number assignee
pr_number=$1
assignee=$2
curl -H "Content-Type: application/json" \
-X PATCH \
-H "$AUTH" \
--silent \
--location \
-d "{\"assignees\": [\"$assignee\"], \"labels\": [\"Standard-Change\"]}" \
https://api.github.com/repos/digital-asset/daml/issues/$pr_number
# For the purposes of "common" features, such as assignees and
# labels, PRs are issues as far as the GH API is concerned.
}
rotate() {
local tmp
tmp=$(mktemp)
cp release/rotation $tmp
(tail -n +2 $tmp; head -1 $tmp) > release/rotation
2020-08-03 17:42:00 +03:00
}
2020-08-05 19:58:56 +03:00
reset
NEXT_SLACK=$(head -1 release/rotation | awk '{print $1}')
NEXT_GH=$(head -1 release/rotation | awk '{print $2}')
2020-07-24 19:40:11 +03:00
./release.sh new snapshot
RELEASE=$(head -1 LATEST | awk '{print $2}')
2020-08-05 19:58:56 +03:00
PR_FILE=$(mktemp)
open_pr "auto-release-pr-$(date -I)" \
"release $RELEASE" \
"This PR has been created by a script, which is not very smart and does not have all the context. Please do double-check that the version prefix is correct before merging.\n\n@$NEXT_GH is in charge of this release." \
$PR_FILE
2020-08-03 17:42:00 +03:00
2020-08-05 19:58:56 +03:00
PR=$(cat $PR_FILE)
assign_and_label $PR $NEXT_GH
reset
rotate
open_pr "rotate-after-$RELEASE" \
"rotate release duty after $RELEASE" \
"@$NEXT_GH is taking care of $RELEASE (#$PR), so they get pushed back to the end of the line.\n\nPlease do not merge this before #$PR."