forked from firecracker-microvm/firecracker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease-prepare.sh
executable file
·99 lines (74 loc) · 2.33 KB
/
release-prepare.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/env bash
# Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
set -eu -o pipefail
shopt -s lastpipe
FC_TOOLS_DIR=$(dirname $(realpath $0))
source "$FC_TOOLS_DIR/functions"
FC_ROOT_DIR=$FC_TOOLS_DIR/..
if [ $# -ne 1 ]; then
cat <<EOF
$0 <version>
Example: $0 0.42.0
Prepare a new Firecracker release:
1. Update the version number
2. Generate CREDITS.md and CHANGELOG.md
3. Commit the result
4. Create a link to PR the changes
EOF
exit 1
fi
version=$1
validate_version "$version"
check_local_branch_is_release_branch
# Create GitHub PR link
ORIGIN_URL=$(git config --get remote.origin.url)
GH_USER=$(git config --get github.user)
REPO=$(basename "$ORIGIN_URL" .git)
LOCAL_BRANCH=$(git rev-parse --abbrev-ref HEAD)
RELEASE_BRANCH=firecracker-v$(echo "$version" |cut -d. -f-2)
UPSTREAM=upstream
# In which branch should the change go, in the main repo?
TARGET_BRANCH=main
PATCH=$(echo "$version" |cut -d. -f3)
# If this is a patch release, the target branch should be the release branch
if [ "$PATCH" -gt 0 ]; then
TARGET_BRANCH=$RELEASE_BRANCH
fi
PR_URL="https://github.com/firecracker-microvm/$REPO/compare/$TARGET_BRANCH...$GH_USER:$REPO:$LOCAL_BRANCH?expand=1"
# Update version
$FC_TOOLS_DIR/bump-version.sh "$version"
# Update credits.
say "Updating credits..."
$FC_TOOLS_DIR/update-credits.sh
# Update changelog.
say "Updating changelog..."
sed -i "s/\[Unreleased\]/\[$version\]/g" "$FC_ROOT_DIR/CHANGELOG.md"
# Add all changed files
git add -u
git commit -s -m "chore: release v$version"
# pretty print code
function pp-code {
# grey background
echo "$(SGR 0 48 5 242)$*$(SGR 0)"
}
# pretty print a list item
function pp-li {
bullet=$1; shift
# reset bg-color-5 bold
echo "$(SGR 0 48 5 101)$bullet$(SGR 0 1) $*$(SGR 0)"
}
cat <<EOF
🎉 Almost done!
$(pp-li 1. Check the changes made to the repo:)
$(pp-code git log --patch HEAD~1..HEAD)
$(pp-li 2. Preview the release notes)
$(pp-code ./tools/release-notes.sh "$version")
$(pp-li 3. If you want to undo the changes, run)
$(pp-code git reset --keep HEAD~1)
$(pp-li 4. Review and merge this change)
$(pp-code git push --force -u origin HEAD)
$PR_URL
$(pp-li 5. Once it is reviewed and merged, run the tag script)
$(pp-code ./tools/release-tag.sh $version)
EOF