xref: /freebsd/contrib/libcbor/release.sh (revision 9f44a47fd07924afc035991af15d84e6585dea4f)
1#!/usr/bin/env bash
2
3# Guides my forgetful self through the release process.
4# Usage release.sh VERSION
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"
20
21cd $DIR
22python3 misc/update_version.py "$1"
23
24echo ">>>>> Checking changelog"
25grep -A 10 -F "$1" CHANGELOG.md || true
26prompt "Is the changelog correct and complete?"
27
28echo ">>>>> Checking Doxyfile"
29grep PROJECT_NUMBER Doxyfile
30prompt "Is the Doxyfile version correct?"
31
32echo ">>>>> Checking CMakeLists"
33grep -A 2 'SET(CBOR_VERSION_MAJOR' CMakeLists.txt
34prompt "Is the CMake version correct?"
35
36echo ">>>>> Checking Bazel build"
37grep -A 2 'CBOR_MAJOR_VERSION' examples/bazel/third_party/libcbor/cbor/configuration.h
38prompt "Is the version correct?"
39
40echo ">>>>> Checking docs"
41grep 'version =\|release =' doc/source/conf.py
42prompt "Are the versions correct?"
43
44set -x
45pushd doc
46make clean
47popd
48doxygen
49cd doc
50make html
51cd build
52
53cp -r html libcbor_docs_html
54tar -zcf libcbor_docs.tar.gz libcbor_docs_html
55
56cp -r doxygen/html libcbor_api_docs_html
57tar -zcf libcbor_api_docs.tar.gz libcbor_api_docs_html
58
59mv libcbor_docs.tar.gz libcbor_api_docs.tar.gz "$OUTDIR"
60
61pushd "$OUTDIR"
62cmake "$DIR" -DCMAKE_BUILD_TYPE=Release -DWITH_TESTS=ON
63make
64ctest
65popd
66
67prompt "Will proceed to tag the release with $TAG_NAME."
68git commit -a -m "Release $TAG_NAME"
69git tag "$TAG_NAME"
70git push --set-upstream origin $(git rev-parse --abbrev-ref HEAD)
71git push --tags
72
73set +x
74
75echo "Release ready in $OUTDIR"
76echo "Add the release to GitHub at https://github.com/PJK/libcbor/releases/new *now*"
77prompt "Have you added the release to https://github.com/PJK/libcbor/releases/tag/$TAG_NAME?"
78
79echo "Update the Hombrew formula (https://github.com/Homebrew/homebrew-core/blob/master/Formula/libcbor.rb) *now*"
80echo "HOWTO: https://github.com/Linuxbrew/brew/blob/master/docs/How-To-Open-a-Homebrew-Pull-Request.md"
81prompt "Have you updated the formula?"
82