]> git.lizzy.rs Git - rust.git/blob - src/ci/publish_toolstate.sh
Move CI to new builtin check-toolstate
[rust.git] / src / ci / publish_toolstate.sh
1 #!/bin/sh
2
3 set -eu
4
5 # The following lines are also found in src/bootstrap/toolstate.rs,
6 # so if updating here, please also update that file.
7
8 export MESSAGE_FILE=$(mktemp -t msg.XXXXXX)
9
10 git config --global user.email '7378925+rust-toolstate-update@users.noreply.github.com'
11 git config --global user.name 'Rust Toolstate Update'
12 git config --global credential.helper store
13 printf 'https://%s:x-oauth-basic@github.com\n' "$TOOLSTATE_REPO_ACCESS_TOKEN" \
14     > "$HOME/.git-credentials"
15 git clone --depth=1 $TOOLSTATE_REPO
16
17 cd rust-toolstate
18 FAILURE=1
19 for RETRY_COUNT in 1 2 3 4 5; do
20     #  The purpose is to publish the new "current" toolstate in the toolstate repo.
21     "$BUILD_SOURCESDIRECTORY/src/tools/publish_toolstate.py" "$(git rev-parse HEAD)" \
22         "$(git log --format=%s -n1 HEAD)" \
23         "$MESSAGE_FILE" \
24         "$TOOLSTATE_REPO_ACCESS_TOKEN"
25     # `git commit` failing means nothing to commit.
26     FAILURE=0
27     git commit -a -F "$MESSAGE_FILE" || break
28     # On failure randomly sleep for 0 to 3 seconds as a crude way to introduce jittering.
29     git push origin master && break || sleep $(LC_ALL=C tr -cd 0-3 < /dev/urandom | head -c 1)
30     FAILURE=1
31     git fetch origin master
32     git reset --hard origin/master
33 done