Remove unused views
[releng/builder.git] / jjb / autorelease / prepare-release.sh
1 #!/bin/bash -l
2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2015, 2017 The Linux Foundation and others.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
11 # Script to prepare project for release.
12 #
13 # 1) Drop -SNAPSHOT from all versions
14 # 2) Create git patches (diffs of changes)
15 # 3) Create git bundles (byte exact commit objects)
16 # 4) Create tarball for distribution.
17
18 # RELEASE_TAG=Beryllium-SR1  # Example
19
20 echo "---> prepare-release.sh"
21
22 # Set release tag as $STREAM, when no release tag is passed
23 RELEASE_TAG="${RELEASE_TAG:-${STREAM^}}"
24 # Ensure that the first letter of RELEASE_TAG is uppercase.
25 RELEASE_TAG="${RELEASE_TAG^}"
26
27 # Directory to put git format-patches
28 PATCH_DIR="$WORKSPACE/archives/patches"
29 mkdir -p "$PATCH_DIR"
30
31 # Get the current submodule commit hashes.
32 echo autorelease "$(git rev-parse --verify HEAD)" "${RELEASE_TAG}" \
33     | tee -a "$PATCH_DIR/taglist.log"
34 # Disable SC2154 because we want $path to be the submodule parameter not the shell.
35 # shellcheck disable=SC2154
36 git submodule foreach "echo \$path \$(git rev-parse --verify HEAD) ${RELEASE_TAG} \
37     | tee -a $PATCH_DIR/taglist.log"
38
39 echo "$RELEASE_TAG"
40 find . -name "*.xml" -print0 | xargs -0 sed -i 's/-SNAPSHOT//'
41
42 # Ignore changes to Final distribution since that will be released separately
43 pushd integration/distribution || exit 1
44     git checkout -f opendaylight/pom.xml
45 popd || exit 1
46 git submodule foreach "git commit -am \"Release $RELEASE_TAG\" || true"
47 git commit -am "Release $RELEASE_TAG"
48
49 modules=$(xmlstarlet sel -N x=http://maven.apache.org/POM/4.0.0 -t -m '//x:modules' -v '//x:module' pom.xml)
50 for module in $modules; do
51     pushd "$module" || exit
52     git format-patch --stdout "origin/$GERRIT_BRANCH" > "$PATCH_DIR/${module//\//-}.patch"
53     git bundle create "$PATCH_DIR/${module//\//-}.bundle" "origin/master..HEAD"
54     popd || exit
55 done
56
57 tar cvzf "$WORKSPACE/archives/patches.tar.gz" -C "$WORKSPACE/archives" patches
58 rm "$PATCH_DIR"/*.bundle