2 # release.sh: openocd release process automation
3 # Copyright (C) 2009 by Zachary T Welch <zw@superlucidity.net>
4 # Release under the GNU GPL v2 (or later versions).
6 ## set these to control the build process
10 ## specifies the --next release type: major, minor, micro, rc, tag
12 ## For tag release type, specifies the name of the tag (e.g. "foo").
13 ## The default is the current user name, as found by the 'id' command.
14 #RELEASE_TAG="$(id -un)"
16 source "tools/release/helpers.sh"
18 VERSION_SH
="tools/release/version.sh"
22 usage: $0 <command> ...
24 --next name The branch's next release type: major, minor, micro, rc, tag.
25 --next-tag name The name for the package version tag.
26 --live Perform the actions in the repository.
29 info Show a summary of the next pending release.
30 release Release the current tree as an archive.
33 bootstrap Prepare the working copy for configuration and building.
34 configure Configures the package; runs bootstrap, if needed.
35 build Compiles the project; runs configure, if needed.
38 changelog Generate a new ChangeLog using ${SCM}2cl.
39 package Produce new distributable source archives.
40 stage Move archives to staging area for upload.
43 clean Forces regeneration of results.
44 clean_all Removes all traces of the release process.
45 help Provides this list of commands.
47 For more information about this script, see the Release Processes page
48 in the OpenOCD Developer's Manual (doc/manual/release.txt).
56 echo "Current Release Analysis:"
61 echo -n "Bootstrapping..."
62 .
/bootstrap
2>&1 | perl tools
/logger.pl
> "release-bootstrap.log"
64 maybe_bootstrap
() { [ -f "configure" ] || do_bootstrap
; }
68 echo -n "Configuring..."
69 .
/configure
${CONFIG_OPTS} 2>&1 | perl tools
/logger.pl
> "release-config.log"
71 maybe_configure
() { [ -f "Makefile" ] || do_configure
; }
75 echo -n "Compiling OpenOCD ${PACKAGE_VERSION}"
76 make ${MAKE_OPTS} -C doc stamp-vti
2>&1 \
77 | perl tools
/logger.pl
> "release-version.log"
78 make ${MAKE_OPTS} 2>&1 \
79 | perl tools
/logger.pl
> "release-make.log"
81 maybe_build
() { [ -f "src/openocd" ] || do_build
; }
82 do_build_clean
() { [ -f Makefile
] && make maintainer-clean
>/dev
/null
; }
85 echo "Creating ChangeLog..."
86 local CMD
=tools
/git2cl
/git2cl
87 eval ${CMD} ${OPTS} > ChangeLog
89 do_changelog_clean
() {
90 git checkout ChangeLog
96 echo "Building distribution packages..."
97 make ${MAKE_OPTS} distcheck
2>&1 | perl tools
/logger.pl
> "release-pkg.log"
99 maybe_package
() { [ -f "${PACKAGE_RELEASE}.zip" ] || do_package
; }
101 for EXT
in tar.gz
tar.bz2
zip; do
108 echo "Staging package archives:"
110 for EXT
in tar.gz
tar.bz2
zip; do
111 local FILE
="${PACKAGE_RELEASE}.${EXT}"
112 # create archive signatures
113 for HASH
in md5 sha1
; do
114 echo "sign: ${FILE}.${HASH}"
115 ${HASH}sum "${FILE}" > "archives/${FILE}.${HASH}"
118 mv -v "${FILE}" archives/
121 cp -a ChangeLog archives/
123 do_stage_clean() { rm -v -f -r archives; }
129 rm -v -f release-*.log
136 do_version_commit() {
137 [ "$
*" ] || die "usage
: $0 commit
<message
>"
138 git add configure.in || die "error
: no version changes to commit
"
139 git commit -q -m "$
*" configure.in
142 do_version_finalize() {
143 echo "The
${PACKAGE_NAME} ${RELEASE_VERSION} release.
"
145 ${VERSION_SH} tag remove dev
146 [ -z "${RELEASE_FINAL}" ] || ${VERSION_SH} bump final rc
149 [ "${PACKAGE_VERSION/dev/}" != "${PACKAGE_VERSION}" ]
151 do_release_step_branch() {
152 git checkout -b "v
${RELEASE_VERSION}-release"
155 do_release_step_tag() {
156 do_version_commit "$
(do_version_finalize
)"
158 [ "${PACKAGE_VERSION/dev/}" = "${PACKAGE_VERSION}" ] || \
159 die "'${PACKAGE_NAME}-${PACKAGE_VERSION}' should not be tagged
"
160 local MSG="The
${PACKAGE_STRING} release.
"
161 git tag -m "${MSG}" "v
${PACKAGE_VERSION}"
165 echo -n "Bump
${RELEASE_TYPE} "
166 [ -z "${RELEASE_TAG}" ] || echo -n "-${RELEASE_TAG} "
167 echo -n "version and add
"
168 [ -z "${RELEASE_START_RC}" ] || echo -n "-rc0"
171 ${VERSION_SH} bump "${RELEASE_TYPE}" "${RELEASE_TAG}"
172 [ -z "${RELEASE_START_RC}" ] ||
${VERSION_SH} bump tag rc
173 ${VERSION_SH} tag add dev
175 do_release_step_bump
() {
176 # bump the version number
177 do_version_commit
"$(do_bump_version)"
180 do_release_step_news_msg
() {
182 Archive and recreate NEWS file.
184 Archive released NEWS file as NEWS-${RELEASE_VERSION}.
185 Create new NEWS file from release script template.
188 do_release_step_news
() {
189 # only archive the NEWS file for major/minor releases
190 [ "${RELEASE_TYPE}" = "major" -o "${RELEASE_TYPE}" = "minor" ] || \
192 # archive NEWS and create new one from template
193 git
mv "NEWS" "NEWS-${RELEASE_VERSION}"
196 This file should include items worth mentioning in the
197 OpenOCD ${NEXT_RELEASE_VERSION} source archive release.
199 The following areas of OpenOCD functionality changed in this release:
204 Board, Target, and Interface Configuration Scripts:
208 For more details about what has changed since the last release,
209 see the ChangeLog associated with this source archive. For older NEWS,
210 see the NEWS files associated with each release
(i.e. NEWS-
<version
>).
212 For
more information about contributing
test reports
, bug fixes
, or new
213 features and device support
, please
read the new Developer Manual
(or
214 the BUGS and PATCHES files
in the
source archive
).
218 local MSG
="$(do_release_step_news_msg)"
219 git commit
-q -m "${MSG}" NEWS
"NEWS-${RELEASE_VERSION}"
222 do_release_step_package
() {
223 [ -z "${RELEASE_FAST}" ] ||
return 0
225 git checkout
-q "v${RELEASE_VERSION}"
230 do_release_step_rebranch
() {
231 # return to the new development head
232 local OLD_BRANCH
="v${RELEASE_VERSION}-release"
233 git checkout
"${OLD_BRANCH}"
235 # create new branch with new version information
237 git checkout
-b "v${PACKAGE_VERSION}"
238 git branch
-d "${OLD_BRANCH}"
241 do_release_step_0
() { do_release_step_branch
; }
242 do_release_step_1
() { do_release_step_tag
; }
243 do_release_step_2
() { do_release_step_bump
; }
244 do_release_step_3
() { do_release_step_news
; }
245 do_release_step_4
() { do_release_step_package
; }
246 do_release_step_5
() { do_release_step_rebranch
; }
249 echo "Starting $CMD for ${RELEASE_VERSION}..."
250 [ "${RELEASE_TYPE}" ] || \
251 die
"The --next release type must be provided. See --help."
255 [ -z "${RELEASE_FAST}" ] ||
return 0
256 echo "Are you sure you want to ${CMD} '${PACKAGE_RELEASE}', "
257 echo -n " to start a new ${RELEASE_TYPE} development cycle? (y/N) "
259 if [ "${ANSWER}" != 'y' ]; then
260 echo "Live release aborted!"
263 do_countdown
"Starting live release"
267 for i
in $
(seq 5 -1 1); do
278 "do_release_step_${i}"
287 for i
in $
(seq 0 5); do
288 "do_release_step_${i}"
291 do_all
() { do_release
"$@"; }
297 git checkout configure.
in
300 LONGOPTS
="fast,final,start-rc,next-tag:,next:,help"
301 OPTIONS
=$
(getopt
-o 'V,n:' --long "${LONGOPTS}" -n $0 -- "$@")
302 if [ $?
!= 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
303 eval set -- "${OPTIONS}"
319 export RELEASE_TYPE
="$2"
323 export RELEASE_TAG
="$2"
338 echo "Internal error"
344 case "${RELEASE_TYPE}" in
345 major|minor|micro|rc
)
348 [ "${RELEASE_TAG}" ] || RELEASE_TAG
="$(id -u -n)"
353 die
"Unknown release type '${RELEASE_TYPE}'"
358 [ "${CMD}" ] || usage
361 ACTION_CMDS
="bootstrap|configure|build|changelog|package|stage|clean"
362 MISC_CMDS
="all|info|release|branch|reset|help|usage"
363 CLEAN_CMDS
="build_clean|changelog_clean|package_clean|stage_clean|clean_all"
364 CMDS
="|${ACTION_CMDS}|${CLEAN_CMDS}|${MISC_CMDS}|"
365 is_command
() { echo "${CMDS}" |
grep "|$1|" >/dev
/null
; }
368 if is_command
"${CMD}"; then
370 echo "Done with '${CMD}'." >&2
372 echo "error: unknown command: '${CMD}'"