blob: d3ca8207be2cbcd23f03923bad9df926707d8908 [file] [log] [blame]
Keir Mierle003dc6a2012-06-18 01:51:09 -07001#!/bin/bash
2#
3# Ceres Solver - A fast non-linear least squares minimizer
4# Copyright 2012 Google Inc. All rights reserved.
5# http://code.google.com/p/ceres-solver/
6#
7# Redistribution and use in source and binary forms, with or without
8# modification, are permitted provided that the following conditions are met:
9#
10# * Redistributions of source code must retain the above copyright notice,
11# this list of conditions and the following disclaimer.
12# * Redistributions in binary form must reproduce the above copyright notice,
13# this list of conditions and the following disclaimer in the documentation
14# and/or other materials provided with the distribution.
15# * Neither the name of Google Inc. nor the names of its contributors may be
16# used to endorse or promote products derived from this software without
17# specific prior written permission.
18#
19# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29# POSSIBILITY OF SUCH DAMAGE.
30#
31# Author: mierle@gmail.com (Keir Mierle)
32#
Sameer Agarwalfa21df82013-02-18 08:48:52 -080033# Note: You will need Sphinx and Pygments installed for this to work.
Keir Mierle003dc6a2012-06-18 01:51:09 -070034
35if [ -z $1 ] ; then
Keir Mierlef4b99112012-07-19 10:31:16 -070036 echo 'usage: scripts/make_release <version>'
37 echo ' must be run from toplevel Ceres source directory'
Keir Mierle003dc6a2012-06-18 01:51:09 -070038 exit 1
39fi
40
41TMP="/tmp/ceres-solver-$1"
Keir Mierlef4b99112012-07-19 10:31:16 -070042DOCS_TMP="/tmp/ceres-solver-docs-$1"
Pablo Specialec51b11c2013-03-12 00:56:56 -070043VERSION=$(grep 'SET(CERES_VERSION_' CMakeLists.txt | \
44 sed -e 's/\(.*\) \(.*\))/\2/' | \
45 tr '\n' '.' | sed -e 's/.$//')
Keir Mierlef4b99112012-07-19 10:31:16 -070046ABI_VERSION=$(grep 'SET(CERES_ABI_VERSION' CMakeLists.txt | \
47 sed -e 's/SET(CERES_ABI_VERSION //' | \
48 sed -e 's/)//')
Keir Mierle7e73d102012-09-11 18:04:09 -070049VERSION_IN_HEADER=$(grep '#define CERES_VERSION' include/ceres/ceres.h | \
50 sed -e 's/#define CERES_VERSION //')
51ABI_VERSION_IN_HEADER=$(grep '#define CERES_ABI_VERSION' \
52 include/ceres/ceres.h | \
53 sed -e 's/#define CERES_ABI_VERSION //')
Taylor Braun-Jones70701742013-02-15 19:09:48 -050054VERSION_IN_SPEC=$(grep '^Version:' scripts/ceres-solver.spec | \
55 sed -e 's/Version: *//')
Keir Mierlef4b99112012-07-19 10:31:16 -070056GIT_COMMIT=$(git log -1 HEAD |grep commit)
57
58if [[ $1 != $VERSION ]] ; then
Keir Mierle7e73d102012-09-11 18:04:09 -070059 echo "ERROR: Version from the command line $1 does not match CERES_VERSION"
60 echo " in CMakeLists.txt, which is $VERSION. You may not be in the "
61 echo " toplevel source dir."
62 exit 1
63fi
64
65if [[ $VERSION_IN_HEADER != $VERSION ]] ; then
66 echo "ERROR: CERES_VERSION version from include/ceres/ceres.h, which is"
67 echo " $VERSION_IN_HEADER, does not match the ABI version"
68 echo " from the toplevel CMakeLists.txt, which is $ABI_VERSION."
69 echo " You may not be in the toplevel source directory, or the"
70 echo " versions are out of sync."
71 exit 1
72fi
73
74if [[ $ABI_VERSION_IN_HEADER != $ABI_VERSION ]] ; then
75 echo "ERROR: CERES_ABI_VERSION from include/ceres/ceres.h, which is"
76 echo " $ABI_VERSION_IN_HEADER, does not match the ABI version"
77 echo " from the toplevel CMakeLists.txt, which is $ABI_VERSION."
78 echo " You may not be in the toplevel source directory, or the"
79 echo " versions are out of sync."
Keir Mierlef4b99112012-07-19 10:31:16 -070080 exit 1
81fi
Keir Mierle003dc6a2012-06-18 01:51:09 -070082
Taylor Braun-Jones70701742013-02-15 19:09:48 -050083if [[ $VERSION_IN_SPEC != $VERSION ]] ; then
84 echo "ERROR: Version string from scripts/ceres-solver.spec, which is"
85 echo " $VERSION_IN_SPEC, does not match the version"
86 echo " from the toplevel CMakeLists.txt, which is $ABI_VERSION."
87 echo " You may not be in the toplevel source directory, or the"
88 echo " versions are out of sync."
89 exit 1
90fi
91
Pablo Specialec51b11c2013-03-12 00:56:56 -070092# Export repository.
93git checkout-index -f -a --prefix=$TMP/
Keir Mierle003dc6a2012-06-18 01:51:09 -070094
Keir Mierlef4b99112012-07-19 10:31:16 -070095# Build the VERSION file.
96VERSIONFILE=$TMP/VERSION
97echo "version $VERSION" >> $VERSIONFILE
98echo "abi_version $VERSION" >> $VERSIONFILE
99echo "$GIT_COMMIT" >> $VERSIONFILE
100
101# Build the documentation.
Sameer Agarwalfa21df82013-02-18 08:48:52 -0800102python $TMP/scripts/make_docs.py $TMP $DOCS_TMP
103cp -pr $DOCS_TMP/html $TMP/docs
Keir Mierle003dc6a2012-06-18 01:51:09 -0700104
105# Build the tarball.
106cd /tmp
107tar -cvzf "ceres-solver-$1.tar.gz" "ceres-solver-$1"
108
109# Don't leave a mess behind.
Keir Mierle003dc6a2012-06-18 01:51:09 -0700110rm -rf $TMP
Sameer Agarwal2160c5b2013-02-24 14:15:45 -0800111rm -rf $DOCS_TMP
Keir Mierle003dc6a2012-06-18 01:51:09 -0700112
Keir Mierlef4b99112012-07-19 10:31:16 -0700113# Reminder to upload.
Taylor Braun-Jones70701742013-02-15 19:09:48 -0500114cat <<EOF
115
116TODO:
117 - Upload /tmp/ceres-solver-$1.tar.gz
118
119 - Update the release string in scripts/ceres-solver.spec if this is a RC
120 release or the first release after a RC release.
121
122 - Build and upload RPM package.
123
124EOF