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