PavolVican | 384786e | 2017-07-12 15:31:20 +0200 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | if [ "$TRAVIS_PULL_REQUEST" == "true" -o "$TRAVIS_EVENT_TYPE" != "cron" ] ; then |
| 4 | exit 0 |
| 5 | fi |
| 6 | # check osb_user and osb_pass |
| 7 | if [ -z "${osb_user}" -o -z "${osb_pass}" ]; then |
| 8 | exit 0 |
| 9 | fi |
| 10 | |
| 11 | # fill username and password for opensuse build and downlaod last package information |
| 12 | echo -e "[general]\napiurl = https://api.opensuse.org\n\n[https://api.opensuse.org]\nuser = ${osb_user}\npass = ${osb_pass}" >~/.oscrc |
| 13 | cd ./build_all |
| 14 | if [ $TRAVIS_BRANCH == "devel" ]; then |
| 15 | package="home:liberouter/libnetconf2-experimental" |
| 16 | name="libnetconf2-experimental" |
| 17 | else |
| 18 | package="home:liberouter/libnetconf2" |
| 19 | name="libnetconf2" |
| 20 | fi |
| 21 | osc checkout home:liberouter |
| 22 | cp $package/libnetconf2.spec $package/debian.changelog home:liberouter |
| 23 | cp build-packages/* $package |
| 24 | cd $package |
| 25 | |
| 26 | # check versions |
| 27 | VERSION=$(cat libnetconf2.spec | grep "Version: " | awk '{print $NF}') |
| 28 | OLDVERSION=$(cat ../libnetconf2.spec | grep "Version: " | awk '{print $NF}') |
| 29 | if [ "$VERSION" == "$OLDVERSION" ]; then |
| 30 | exit 0 |
| 31 | fi |
| 32 | |
| 33 | # create new changelog and paste old changelog |
| 34 | logtime=$(git log -i --grep="VERSION .* $OLDVERSION" | grep "Date: " | sed 's/Date:[ ]*//') |
| 35 | echo -e "$name ($VERSION) stable; urgency=low\n" >debian.changelog |
| 36 | git log --since="$logtime" --pretty=format:" * %s (%aN)%n" | grep "BUGFIX\|CHANGE\|FEATURE" >>debian.changelog |
| 37 | git log -1 --pretty=format:"%n -- %aN <%aE> %aD%n" >>debian.changelog |
| 38 | echo -e "\n" >>debian.changelog |
| 39 | cat ../debian.changelog >>debian.changelog |
| 40 | git log -1 --date=format:'%a %b %d %Y' --pretty=format:"* %ad %aN <%aE>" | tr -d "\n" >>libnetconf2.spec |
| 41 | echo " $VERSION" >>libnetconf2.spec |
| 42 | git log --since="$logtime" --pretty=format:"- %s (%aN)" | grep "BUGFIX\|CHANGE\|FEATURE" >>libnetconf2.spec |
| 43 | echo -e "\n" >>libnetconf2.spec |
| 44 | cat ../libnetconf2.spec | sed -e '1,/%changelog/d' >>libnetconf2.spec |
| 45 | |
| 46 | # download source and update to opensuse build |
| 47 | wget "https://github.com/CESNET/libnetconf2/archive/$TRAVIS_BRANCH.tar.gz" -O $TRAVIS_BRANCH.tar.gz |
| 48 | osc commit -m travis-update |