forked from containers/buildah
-
Notifications
You must be signed in to change notification settings - Fork 2
/
release.sh
executable file
·107 lines (93 loc) · 2.39 KB
/
release.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
100
101
102
103
104
105
106
107
#!/bin/sh
#
# Cut a buildah release. Usage:
#
# $ hack/release.sh <version> <next-version>
#
# For example:
#
# $ hack/release.sh 1.2.3 1.3.0
#
# for "I'm cutting 1.2.3, and want to use 1.3.0-dev for future work".
VERSION="$1"
NEXT_VERSION="$2"
DATE=$(date '+%Y-%m-%d')
LAST_TAG=$(git describe --tags --abbrev=0)
write_go_version()
{
LOCAL_VERSION="$1"
sed -i "s/^\(.*Version = \"\).*/\1${LOCAL_VERSION}\"/" define/types.go
}
write_spec_version()
{
LOCAL_VERSION="$1"
sed -i "s/^\(Version: *\).*/\1${LOCAL_VERSION}/" contrib/rpm/buildah.spec
}
write_spec_changelog()
{
sed '/\*.*-dev-1/d' -i ./contrib/rpm/buildah.spec
VERSION=$1
date=$(date "+%a %b %d, %Y")
name=$(getent passwd $USERNAME | cut -d ':' -f 5)
echo "* ${date} ${name} <${USER}@redhat.com> ${VERSION}-1" >.changelog.txt
if [[ "${VERSION}" != *-dev ]]; then
git log --no-merges --format='- %s' "${LAST_TAG}..HEAD" >>.changelog.txt
else
echo "" >>.changelog.txt
fi
sed '/^%changelog.*/r .changelog.txt' -i ./contrib/rpm/buildah.spec
rm -f .changelog.txt
}
write_makefile_epoch()
{
LOCAL_EPOCH="$1"
sed -i "s/^\(EPOCH_TEST_COMMIT ?= \).*/\1${LOCAL_EPOCH}/" Makefile
}
write_changelog()
{
echo "- Changelog for v${VERSION} (${DATE})" >.changelog.txt &&
git log --no-merges --format=' * %s' "${LAST_TAG}..HEAD" >>.changelog.txt &&
echo >>.changelog.txt &&
cat changelog.txt >>.changelog.txt &&
mv -f .changelog.txt changelog.txt
echo "
## v${VERSION} (${DATE})
" >.CHANGELOG.md &&
git log --no-merges --format=' %s' "${LAST_TAG}..HEAD" >>.CHANGELOG.md &&
sed -i -e '/# Changelog/r .CHANGELOG.md' CHANGELOG.md &&
rm -f .CHANGELOG.md
}
release_commit()
{
write_go_version "${VERSION}" &&
write_spec_version "${VERSION}" &&
write_spec_changelog "${VERSION}" &&
write_changelog &&
git commit -asm "Bump to v${VERSION}
[NO TESTS NEEDED]
"
}
dev_version_commit()
{
write_go_version "${NEXT_VERSION}-dev" &&
write_spec_version "${NEXT_VERSION}-dev" &&
write_spec_changelog "${NEXT_VERSION}-dev" &&
git commit -asm "Bump to v${NEXT_VERSION}-dev
[NO TESTS NEEDED]
"
}
epoch_commit()
{
LOCAL_EPOCH="$1"
write_makefile_epoch "${LOCAL_EPOCH}" &&
git commit -asm 'Bump gitvalidation epoch
[NO TESTS NEEDED]
'
}
git fetch origin &&
git checkout -b "bump-${VERSION}" origin/main &&
EPOCH=$(git rev-parse HEAD) &&
release_commit &&
git tag -s -m "version ${VERSION}" "v${VERSION}" &&
dev_version_commit &&
epoch_commit "${EPOCH}"