aboutsummaryrefslogtreecommitdiff
path: root/hack/release.sh
blob: 7925d55ad5a28ec99424a50b3ecb896551604f15 (plain)
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
#!/bin/sh
#
# Cut a libpod 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"

if test "${NEXT_VERSION}" != "${NEXT_VERSION%-dev}"
then
	echo "The next-version argument '${NEXT_VERSION}' should not end in '-dev'." >&2
	echo "This script will add the -dev suffix as needed internally.  Try:" >&2
	echo "  $0 ${VERSION} ${NEXT_VERSION%-dev}" >&2
	exit 1
fi

DATE=$(date '+%Y-%m-%d')
LAST_TAG=$(git describe --tags --abbrev=0)

write_go_version()
{
	LOCAL_VERSION="$1"
	sed -i "s/^\(var Version = semver.MustParse( *\"\).*/\1${LOCAL_VERSION}\")/" version/version.go
}

write_spec_version()
{
	LOCAL_VERSION="$1"
	sed -i "s/^\(Version: *\).*/\1${LOCAL_VERSION}/" contrib/spec/podman.spec.in
}

release_commit()
{
	write_go_version "${VERSION}" &&
	write_spec_version "${VERSION}" &&
	git commit -asm "Bump to v${VERSION}"
}

dev_version_commit()
{
	write_go_version "${NEXT_VERSION}-dev" &&
	write_spec_version "${NEXT_VERSION}" &&
	git commit -asm "Bump to v${NEXT_VERSION}-dev"
}

git fetch origin &&
git checkout -b "bump-${VERSION}" origin/main &&
release_commit &&
git tag -s -m "version ${VERSION}" "v${VERSION}" &&
dev_version_commit