forked from theforeman/foreman-installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release_module
executable file
·53 lines (45 loc) · 1.99 KB
/
release_module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash -e
die() {
echo $* >&2
exit 1
}
if [ $# -ne 2 -o x$1 = "x-h" -o x$1 = "x--help" ]; then
echo "usage: $0 <module name> <version>"
echo
echo " update CHANGELOG.md before running this script and git add or commit it"
echo " only local changes will be made, no git pushes"
echo
die "incorrect arguments supplied"
fi
MODULE=$1
VERSION=$2
test -d modules/$MODULE || die "no such module $MODULE"
test -e modules/$MODULE/CHANGELOG.md || die "no CHANGELOG.md found in $MODULE"
test -e modules/$MODULE/Modulefile || die "no Modulefile found in $MODULE"
grep -q '^version' modules/$MODULE/Modulefile || die "no version found in Modulefile"
grep -xq "## ${VERSION}" modules/$MODULE/CHANGELOG.md || die "no '## ${VERSION}' found in CHANGELOG. Do this first, and add to your index or commit it."
(cd modules/$MODULE && git rev-parse $VERSION >/dev/null 2>&1) && die "tag for ${VERSION} already exists"
(cd modules/$MODULE && [ x$(git rev-parse --abbrev-ref HEAD) = xmaster ] ) || die "$MODULE isn't on master branch"
(cd modules/$MODULE && [ x$(git diff --shortstat -- CHANGELOG.md | wc -l) = x0 ] ) || die "CHANGELOG.md isn't in the git index or committed"
[[ "$VERSION" =~ ^[0-9\.]+$ ]] || die "invalid version number"
type puppet >/dev/null 2>&1 || die "puppet not installed"
TMPDIR=$(mktemp -d)
trap "rm -rf $TMPDIR" EXIT ERR
pushd modules/$MODULE >/dev/null
sed -i "/^version/ s/ .*/ '${VERSION}'/" Modulefile
git add Modulefile
git ci -m "Release ${VERSION}"
git tag -m "Release ${VERSION}" $VERSION
git archive $VERSION | (cd $TMPDIR && tar -xf -)
popd >/dev/null
# Use a clean copy, as p-m-build isn't good at ignoring files
puppet module build $TMPDIR
PKGS=$(cd $TMPDIR/pkg && echo *.tar.gz)
cp -a $TMPDIR/pkg/* pkg/
echo
echo Built pkg/$PKGS
echo
echo 'Next steps:'
echo " 1. (cd modules/${MODULE} && git push origin master && git push origin ${VERSION})"
echo " 2. visit http://forge.puppetlabs.com/theforeman/${MODULE} and log in"
echo " 3. click Upload a New Release, and upload $(pwd)/pkg/$PKGS"