Simplify patches tarball creation
[releng/builder.git] / jjb / autorelease / include-raw-autorelease-release-versions.sh
1 #!/bin/bash
2 # @License EPL-1.0 <http://spdx.org/licenses/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
12 # RELEASE_TAG=Beryllium-SR1  # Example
13 # RELEASE_BRANCH=stable/beryllium  # Example
14
15 LFTOOLS_DIR="$WORKSPACE/.venv-lftools"
16 if [ ! -d "$LFTOOLS_DIR" ]
17 then
18     virtualenv "$LFTOOLS_DIR"
19     # shellcheck disable=SC1090
20     source "$LFTOOLS_DIR/bin/activate"
21     pip install --upgrade pip
22     pip freeze
23     pip install lftools
24 fi
25 # shellcheck disable=SC1090
26 source "$LFTOOLS_DIR/bin/activate"
27
28 # Directory to put git format-patches
29 PATCH_DIR="$WORKSPACE/patches"
30
31 echo "$RELEASE_TAG"
32 lftools version release "$RELEASE_TAG"
33 git submodule foreach "git commit -am \"Release $RELEASE_TAG\" || true"
34 git commit -am "Release $RELEASE_TAG"
35
36 mkdir patches
37 mv taglist.log "$PATCH_DIR"
38 modules=$(xmlstarlet sel -N x=http://maven.apache.org/POM/4.0.0 -t -m '//x:modules' -v '//x:module' pom.xml)
39 for module in $modules; do
40     pushd "$module"
41     git format-patch --stdout "origin/$RELEASE_BRANCH" > "$PATCH_DIR/${module//\//-}.patch"
42     git bundle create "$PATCH_DIR/${module//\//-}.bundle" "origin/master..HEAD"
43     popd
44 done
45
46 tar cvzf patches.tar.gz -C "$WORKSPACE" patches
47 rm "$PATCH_DIR"/*.bundle