xref: /freebsd/contrib/libcbor/release.sh (revision a259b98fa211ed87bfee58c575de4e2de94ee0fa)
1#!/usr/bin/env bash
2
3# Guides my forgetful self through the release process.
4# Usage: release.sh 0.42.0
5
6set -e
7
8function prompt() {
9	echo "$1 Confirm with 'Yes'"
10	read check
11	if [ "$check" != "Yes" ]; then
12		echo "Aborting..."
13		exit 1
14	fi
15}
16# http://stackoverflow.com/questions/59895/getting-the-source-directory-of-a-bash-script-from-within
17DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
18OUTDIR=$(mktemp -d)
19TAG_NAME="v$1"
20BRANCH_NAME="release-$1"
21
22
23echo ">>>>> Bumping version"
24cd $DIR
25git checkout -b "$BRANCH_NAME"
26python3 misc/update_version.py "$1"
27git commit -a -m "Bump version to $1"
28git log -2
29prompt "Check the repository state, everything looks good?"
30
31echo ">>>>> Checking changelog"
32grep -A 10 -F "$1" CHANGELOG.md || true
33prompt "Is the changelog correct and complete?"
34
35echo ">>>>> Checking Doxyfile"
36grep PROJECT_NUMBER Doxyfile
37prompt "Is the Doxyfile version correct?"
38
39echo ">>>>> Checking CMakeLists"
40grep -A 2 'set(CBOR_VERSION_MAJOR' CMakeLists.txt
41prompt "Is the CMake version correct?"
42
43echo ">>>>> Checking Bazel build"
44grep -A 2 'CBOR_MAJOR_VERSION' examples/bazel/third_party/libcbor/cbor/configuration.h
45prompt "Is the version correct?"
46
47echo ">>>>> Checking docs"
48grep 'version =\|release =' doc/source/conf.py
49prompt "Are the versions correct?"
50
51set -x
52pushd doc
53make clean
54popd
55doxygen
56cd doc
57make html
58cd build
59
60cp -r html libcbor_docs_html
61tar -zcf libcbor_docs.tar.gz libcbor_docs_html
62
63cp -r doxygen/html libcbor_api_docs_html
64tar -zcf libcbor_api_docs.tar.gz libcbor_api_docs_html
65
66mv libcbor_docs.tar.gz libcbor_api_docs.tar.gz "$OUTDIR"
67
68pushd "$OUTDIR"
69cmake "$DIR" -DCMAKE_BUILD_TYPE=Release -DWITH_TESTS=ON
70make
71ctest
72popd
73
74echo ">>>>> Pushing version bump branch"
75git push --set-upstream origin $(git rev-parse --abbrev-ref HEAD)
76echo "Open and merge PR: https://github.com/PJK/libcbor/pull/new/${BRANCH_NAME}"
77prompt "Did you merge the PR?"
78
79git checkout master
80git pull
81
82prompt "Will proceed to tag the release with $TAG_NAME."
83git tag "$TAG_NAME"
84git push --set-upstream origin $(git rev-parse --abbrev-ref HEAD)
85git push --tags
86
87set +x
88
89echo "Release ready in $OUTDIR"
90echo "Add the release to GitHub at https://github.com/PJK/libcbor/releases/new *now*"
91prompt "Have you added the release to https://github.com/PJK/libcbor/releases/tag/$TAG_NAME?"
92
93echo "Update the Hombrew formula (https://github.com/Homebrew/homebrew-core/blob/master/Formula/libcbor.rb) *now*"
94echo "HOWTO: https://github.com/Linuxbrew/brew/blob/master/docs/How-To-Open-a-Homebrew-Pull-Request.md"
95prompt "Have you updated the formula?"
96