daml/ci/cron/wednesday.yml
Gary Verhaegen 93f449d245
rename master to main (#8245)
As we strive for more inclusiveness, we are becoming less comfortable
with historically-charged terms being used in our everyday work.

This is targeted for merge on Dec 26, _after_ the necessary
corresponding changes at both the GitHub and Azure Pipelines levels.

CHANGELOG_BEGIN

- DAML Connect development is now conducted from the `main` branch,
  rather than the `master` one. If you had any dependency on the
  digital-asset/daml repository, you will need to update this parameter.

CHANGELOG_END
2020-12-27 14:19:07 +01:00

120 lines
3.9 KiB
YAML

# Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
pr: none
trigger: none
schedules:
- cron: "0 6 * * Wed"
displayName: weekly snapshot
branches:
include:
- main
always: true
jobs:
- job: open_release_pr
timeoutInMinutes: 60
pool:
vmImage: ubuntu-latest
steps:
- checkout: self
persistCredentials: true
- template: ../bash-lib.yml
parameters:
var_name: bash_lib
- bash: |
set -euo pipefail
source "$(bash_lib)"
AUTH="$(get_gh_auth_header)"
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"
out="${4:-}"
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")" \
'{"title": $title, "head": $branch, "base": "main", "body": $body}' \
| 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 \
--definition-name "digital-asset.daml" \
--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
}
reset
NEXT_SLACK=$(head -1 release/rotation | awk '{print $1}')
NEXT_GH=$(head -1 release/rotation | awk '{print $2}')
./release.sh new snapshot
RELEASE=$(head -1 LATEST | awk '{print $2}')
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
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."