|
| 1 | +#!/bin/sh |
| 2 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 3 | +# or more contributor license agreements. See the NOTICE file |
| 4 | +# distributed with this work for additional information |
| 5 | +# regarding copyright ownership. The ASF licenses this file |
| 6 | +# to you under the Apache License, Version 2.0 (the |
| 7 | +# "License"); you may not use this file except in compliance |
| 8 | +# with the License. You may obtain a copy of the License at |
| 9 | +# |
| 10 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +# |
| 12 | +# Unless required by applicable law or agreed to in writing, |
| 13 | +# software distributed under the License is distributed on an |
| 14 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | +# KIND, either express or implied. See the License for the |
| 16 | +# specific language governing permissions and limitations |
| 17 | +# under the License. |
| 18 | + |
| 19 | +version='TESTBUILD' |
| 20 | +sourcedir=~/cloudstack-terraform-provider |
| 21 | +outputdir=/tmp/cloudstack-terraform-provider-build/ |
| 22 | +branch='master' |
| 23 | +tag='no' |
| 24 | +certid='X' |
| 25 | +committosvn='X' |
| 26 | + |
| 27 | +usage(){ |
| 28 | + echo "usage: $0 -v version [-b branch] [-s source dir] [-o output dir] [-t] [-u] [-c] [-h]" |
| 29 | + echo " -v sets the version" |
| 30 | + echo " -b sets the branch (defaults to 'master')" |
| 31 | + echo " -s sets the source directory (defaults to $sourcedir)" |
| 32 | + echo " -o sets the output directory (defaults to $outputdir)" |
| 33 | + echo " -t tags the git repo with the version" |
| 34 | + echo " -u sets the certificate ID to sign with (if not provided, the default key is attempted)" |
| 35 | + echo " -c commits build artifacts to cloudstack dev dist dir in svn" |
| 36 | + echo " -h" |
| 37 | +} |
| 38 | + |
| 39 | +while getopts v:s:o:b:u:tch opt |
| 40 | +do |
| 41 | + case "$opt" in |
| 42 | + v) version="$OPTARG";; |
| 43 | + s) sourcedir="$OPTARG";; |
| 44 | + o) outputdir="$OPTARG";; |
| 45 | + b) branch="$OPTARG";; |
| 46 | + t) tag="yes";; |
| 47 | + u) certid="$OPTARG";; |
| 48 | + c) committosvn="yes";; |
| 49 | + h) usage |
| 50 | + exit 0;; |
| 51 | + /?) # unknown flag |
| 52 | + usage |
| 53 | + exit 1;; |
| 54 | + esac |
| 55 | +done |
| 56 | +shift `expr $OPTIND - 1` |
| 57 | + |
| 58 | +if [ $version == "TESTBUILD" ]; then |
| 59 | + echo >&2 "A version must be specified with the -v option: performrelease.sh -v 0.4.0.RC1" |
| 60 | + exit 1 |
| 61 | +fi |
| 62 | + |
| 63 | +echo "Using version: $version" |
| 64 | +echo "Using source directory: $sourcedir" |
| 65 | +echo "Using output directory: $outputdir" |
| 66 | +echo "Using branch: $branch" |
| 67 | +if [ "$tag" == "yes" ]; then |
| 68 | + if [ "$certid" == "X" ]; then |
| 69 | + echo "Tagging the branch with the version number, and signing the branch with your default certificate." |
| 70 | + else |
| 71 | + echo "Tagging the branch with the version number, and signing the branch with certificate ID $certid." |
| 72 | + fi |
| 73 | +else |
| 74 | + echo "The branch will not be tagged. You should consider doing this." |
| 75 | +fi |
| 76 | + |
| 77 | +if [ -d "$outputdir" ]; then |
| 78 | + rm -r $outputdir/* |
| 79 | +else |
| 80 | + mkdir $outputdir |
| 81 | +fi |
| 82 | + |
| 83 | +cd $sourcedir |
| 84 | + |
| 85 | +echo 'checking out correct branch' |
| 86 | +git checkout $branch |
| 87 | + |
| 88 | +git clean -f |
| 89 | + |
| 90 | +export commitsh=`git show HEAD | head -n 1 | cut -d ' ' -f 2` |
| 91 | +echo "releasing as $commitsh" |
| 92 | + |
| 93 | +echo 'archiving' |
| 94 | +git archive --format=tar --prefix=apache-cloudstack-terraform-provider-$version-src/ $branch > $outputdir/apache-cloudstack-terraform-provider-$version-src.tar |
| 95 | +bzip2 $outputdir/apache-cloudstack-terraform-provider-$version-src.tar |
| 96 | + |
| 97 | +cd $outputdir |
| 98 | +echo 'armor' |
| 99 | +if [ "$certid" == "X" ]; then |
| 100 | + gpg -v --armor --output apache-cloudstack-terraform-provider-$version-src.tar.bz2.asc --detach-sig apache-cloudstack-terraform-provider-$version-src.tar.bz2 |
| 101 | +else |
| 102 | + gpg -v --default-key $certid --armor --output apache-cloudstack-terraform-provider-$version-src.tar.bz2.asc --detach-sig apache-cloudstack-terraform-provider-$version-src.tar.bz2 |
| 103 | +fi |
| 104 | + |
| 105 | +echo 'md5' |
| 106 | +gpg -v --print-md MD5 apache-cloudstack-terraform-provider-$version-src.tar.bz2 > apache-cloudstack-terraform-provider-$version-src.tar.bz2.md5 |
| 107 | + |
| 108 | +echo 'sha512' |
| 109 | +gpg -v --print-md SHA512 apache-cloudstack-terraform-provider-$version-src.tar.bz2 > apache-cloudstack-terraform-provider-$version-src.tar.bz2.sha512 |
| 110 | + |
| 111 | +echo 'verify' |
| 112 | +gpg -v --verify apache-cloudstack-terraform-provider-$version-src.tar.bz2.asc apache-cloudstack-terraform-provider-$version-src.tar.bz2 |
| 113 | + |
| 114 | +if [ "$tag" == "yes" ]; then |
| 115 | + echo 'tag' |
| 116 | + cd $sourcedir |
| 117 | + if [ "$certid" == "X" ]; then |
| 118 | + git tag -s $version -m "Tagging release $version on branch $branch." |
| 119 | + else |
| 120 | + git tag -u $certid -s $version -m "Tagging release $version on branch $branch." |
| 121 | + fi |
| 122 | +fi |
| 123 | + |
| 124 | +if [ "$committosvn" == "yes" ]; then |
| 125 | + echo 'committing artifacts to svn' |
| 126 | + rm -Rf /tmp/cloudstack-dev-dist |
| 127 | + cd /tmp |
| 128 | + svn co https://dist.apache.org/repos/dist/dev/cloudstack/ cloudstack-dev-dist |
| 129 | + cd cloudstack-dev-dist |
| 130 | + if [ -d "terraform-provider-$version" ]; then |
| 131 | + cd terraform-provider-$version |
| 132 | + svn rm * |
| 133 | + else |
| 134 | + mkdir terraform-provider-$version |
| 135 | + svn add terraform-provider-$version |
| 136 | + cd terraform-provider-$version |
| 137 | + fi |
| 138 | + cp $outputdir/apache-cloudstack-terraform-provider-$version-src.tar.bz2 . |
| 139 | + cp $outputdir/apache-cloudstack-terraform-provider-$version-src.tar.bz2.asc . |
| 140 | + cp $outputdir/apache-cloudstack-terraform-provider-$version-src.tar.bz2.md5 . |
| 141 | + cp $outputdir/apache-cloudstack-terraform-provider-$version-src.tar.bz2.sha512 . |
| 142 | + svn add apache-cloudstack-terraform-provider-$version-src.tar.bz2 |
| 143 | + svn add apache-cloudstack-terraform-provider-$version-src.tar.bz2.asc |
| 144 | + svn add apache-cloudstack-terraform-provider-$version-src.tar.bz2.md5 |
| 145 | + svn add apache-cloudstack-terraform-provider-$version-src.tar.bz2.sha512 |
| 146 | + svn commit -m "Committing release candidate artifacts for $version to dist/dev/cloudstack in preparation for release vote" |
| 147 | +fi |
| 148 | + |
| 149 | +echo "completed. use commit-sh of $commitsh when starting the VOTE thread" |
0 commit comments