-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathupdate-tezos.sh
executable file
·77 lines (61 loc) · 3.29 KB
/
update-tezos.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env bash
# SPDX-FileCopyrightText: 2021 Oxhead Alpha
# SPDX-License-Identifier: LicenseRef-MIT-OA
# This script fetches the latest tag from the https://gitlab.com/tezos/tezos/ repository,
# compares it with the version presented in the nix/nix/sources.json, and performs an
# update if the versions are different
set -e
git config user.name "serokell-bot" # necessary for pushing
git config user.email "[email protected]"
git fetch --all
# Get latest tag from tezos/tezos
git clone https://gitlab.com/tezos/tezos.git upstream-repo
cd upstream-repo
latest_upstream_tag_hash="$(git rev-list --tags --max-count=1)"
latest_upstream_tag="$(git describe --tags "$latest_upstream_tag_hash")"
opam_repository_tag='' # will be set by version.sh
git checkout "$latest_upstream_tag"
source scripts/version.sh
# copying metadata from octez repo
cp script-inputs/released-executables ../docker/octez-executables
cp script-inputs/active_protocol_versions_without_number ../docker/active-protocols
cd ..
rm -rf upstream-repo
packaging_tag="$([[ "$latest_upstream_tag" =~ octez-(v.*) ]] && echo "${BASH_REMATCH[1]}")"
branch_name="auto/$packaging_tag-release"
our_tezos_tag="$(jq -r '.tezos_ref' meta.json | cut -d'/' -f3)"
new_meta=$(jq ".tezos_ref=\"$latest_upstream_tag\"" meta.json)
echo "$new_meta" > meta.json
if [[ "$latest_upstream_tag" != "$our_tezos_tag" ]]; then
# If corresponding branch doesn't exist yet, then the release PR
# wasn't created
if ! git rev-parse --verify "$branch_name"; then
git switch -c "$branch_name"
echo "Updating Tezos to $packaging_tag"
./scripts/update-input.py tezos "$latest_upstream_tag_hash"
./scripts/update-input.py opam-repository "$opam_repository_tag"
git commit -a -m "[Chore] Bump Tezos sources to $packaging_tag" --gpg-sign="[email protected]"
./scripts/update-brew-formulae.sh "$latest_upstream_tag" "$packaging_tag-1"
git commit -a -m "[Chore] Update brew formulae for $packaging_tag" --gpg-sign="[email protected]"
sed -i 's/"release": "[0-9]\+"/"release": "1"/' ./meta.json
# Update version of tezos-baking package
sed -i "s/version = .*/version = \"$packaging_tag\"/" ./baking/pyproject.toml
# Commit may fail when release number wasn't updated since the last release
git commit -a -m "[Chore] Reset release number for $packaging_tag" --gpg-sign="[email protected]" || \
(true; echo "release number wasn't updated")
sed -i 's/letter_version *= *"[a-z]"/letter_version = ""/' ./docker/package/model.py
# Commit may fail when the letter version wasn't updated since the last release
git commit -a -m "[Chore] Reset letter_version for $packaging_tag" --gpg-sign="[email protected]" || \
(true; echo "letter_version wasn't reset")
./scripts/update-release-binaries.py
pushd docker
python3 -m package.update-test-binaries-list
popd
git commit -a -m "[Chore] Update release binaries for $packaging_tag" --gpg-sign="[email protected]" || \
(true; echo "lists of binaries and protocols weren't updated")
git push --set-upstream origin "$branch_name"
gh pr create -B master -t "[Chore] $packaging_tag release" -F .github/release_pull_request_template.md
fi
else
echo "Our version is the same as the latest tag in the upstream repository"
fi