Chore: Upgrade Jenkins-job-builder to 6.3.0
[releng/global-jjb.git] / shell / maven-patch-release.sh
1 #!/bin/bash -l
2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 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 echo "---> maven-patch-release.sh"
12 # This script removes the -SNAPSHOT from a project to prepare it for release.
13
14 PATCH_DIR="$WORKSPACE/archives/patches"
15 mkdir -p "$PATCH_DIR"
16
17 # Ensure we fail the job if any steps fail.
18 set -eu -o pipefail
19
20 echo "$PROJECT" "$(git rev-parse --verify HEAD)" | tee -a "$PATCH_DIR/taglist.log"
21 if [[ "${MAVEN_VERSIONS_PLUGIN}" == "false" ]] ; then
22     # Strip -SNAPSHOT from version to prepare release.
23     find . -name "*.xml" -print0 | xargs -0 sed -i 's/-SNAPSHOT//g'
24 fi
25 git commit -am "Release $PROJECT"
26 git format-patch --stdout "origin/$GERRIT_BRANCH" > "$PATCH_DIR/${PROJECT//\//-}.patch"
27 git bundle create "$PATCH_DIR/${PROJECT//\//-}.bundle" "origin/${GERRIT_BRANCH}..HEAD"