forked from heroku/heroku-buildpack-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublish.sh
executable file
·48 lines (40 loc) · 1.24 KB
/
publish.sh
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
#!/bin/bash
set -e
BP_NAME="java"
if [ ! -z "$1" ]; then
pushd . > /dev/null 2>&1
cd /tmp
rm -rf heroku-buildpack-$BP_NAME
git clone [email protected]:heroku/heroku-buildpack-$BP_NAME.git
cd heroku-buildpack-$BP_NAME
git checkout master
headHash=$(git rev-parse HEAD)
find . ! -name '.' ! -name '..' ! -name 'bin' ! -name 'opt' \
! -name 'lib' -maxdepth 1 -print0 | xargs -0 rm -rf --
heroku buildkits:publish $1/$BP_NAME
if [ "$1" = "heroku" ]; then
newTag=$(heroku buildkits:revisions heroku/$BP_NAME | sed -n 2p | grep -o -e "v\d*")
fi
popd > /dev/null 2>&1
echo "Cleaning up..."
rm -rf /tmp/heroku-buildpack-$BP_NAME
if [ "$1" = "heroku" ]; then
if [ "$headHash" = "$(git rev-parse HEAD)" ]; then
echo "Tagging commit $headHash with $newTag... "
git tag $newTag
echo "Updating previous-version tag"
git tag -d previous-version
git push origin :previous-version
git tag previous-version latest-version
echo "Updating latest-version tag"
git tag -d latest-version
git push origin :latest-version
git tag latest-version
git push --tags
fi
fi
echo "Done."
else
echo "You must provide a buildkit organization as an argument!"
exit 1
fi