blob: a8adf4b189333c78178ade2892af052dc47af840 [file] [log] [blame]
PavolVican384786e2017-07-12 15:31:20 +02001#!/usr/bin/env bash
2
Michal Vasko4cb2d722020-04-23 13:49:16 +02003package="libnetconf2"
4url="https://github.com/cesnet/libnetconf2"
5
PavolVican384786e2017-07-12 15:31:20 +02006if [ "$TRAVIS_PULL_REQUEST" == "true" -o "$TRAVIS_EVENT_TYPE" != "cron" ] ; then
7 exit 0
8fi
Michal Vasko4cb2d722020-04-23 13:49:16 +02009
10#install OSC
11sudo apt-get install -y osc
12
PavolVican384786e2017-07-12 15:31:20 +020013# check osb_user and osb_pass
14if [ -z "${osb_user}" -o -z "${osb_pass}" ]; then
15 exit 0
16fi
17
18# fill username and password for opensuse build and downlaod last package information
19echo -e "[general]\napiurl = https://api.opensuse.org\n\n[https://api.opensuse.org]\nuser = ${osb_user}\npass = ${osb_pass}" >~/.oscrc
Michal Vasko34a6d742019-12-10 15:25:07 +010020cd ./build
Michal Vasko4cb2d722020-04-23 13:49:16 +020021
PavolVican384786e2017-07-12 15:31:20 +020022osc checkout home:liberouter
Michal Vasko4cb2d722020-04-23 13:49:16 +020023cp home:liberouter/$package/$package.spec home:liberouter/$package/debian.changelog home:liberouter
24cp build-packages/debian* build-packages/$package* home:liberouter/$package
25cd home:liberouter/$package
PavolVican384786e2017-07-12 15:31:20 +020026
27# check versions
Michal Vasko4cb2d722020-04-23 13:49:16 +020028VERSION=$(cat $package.spec | grep "Version: " | awk '{print $NF}')
29OLDVERSION=$(cat ../$package.spec | grep "Version: " | awk '{print $NF}')
Michal Vasko34a6d742019-12-10 15:25:07 +010030if [ -z "$FORCEVERSION" -a "$VERSION" == "$OLDVERSION" ]; then
PavolVican384786e2017-07-12 15:31:20 +020031 exit 0
32fi
33
34# create new changelog and paste old changelog
Michal Vasko34a6d742019-12-10 15:25:07 +010035if [ "$VERSION" != "$OLDVERSION" ]; then
36 logtime=$(git log -i --grep="VERSION .* $OLDVERSION" | grep "Date: " | sed 's/Date:[ ]*//')
Michal Vasko4cb2d722020-04-23 13:49:16 +020037 echo -e "$package ($VERSION) stable; urgency=low\n" >debian.changelog
Michal Vasko34a6d742019-12-10 15:25:07 +010038 git log --since="$logtime" --pretty=format:" * %s (%aN)%n" | grep "BUGFIX\|CHANGE\|FEATURE" >>debian.changelog
39 git log -1 --pretty=format:"%n -- %aN <%aE> %aD%n" >>debian.changelog
40 echo -e "\n" >>debian.changelog
41 cat ../debian.changelog >>debian.changelog
42fi
43
44if [ "$VERSION" != "$OLDVERSION" ]; then
Michal Vasko4cb2d722020-04-23 13:49:16 +020045 git log -1 --date=format:'%a %b %d %Y' --pretty=format:"* %ad %aN <%aE>" | tr -d "\n" >>$package.spec
46 echo " $VERSION" >>$package.spec
47 git log --since="$logtime" --pretty=format:"- %s (%aN)" | grep "BUGFIX\|CHANGE\|FEATURE" >>$package.spec
48 echo -e "\n" >>$package.spec
Michal Vasko34a6d742019-12-10 15:25:07 +010049fi
Michal Vasko4cb2d722020-04-23 13:49:16 +020050cat ../$package.spec | sed -e '1,/%changelog/d' >>$package.spec
PavolVican384786e2017-07-12 15:31:20 +020051
52# download source and update to opensuse build
Michal Vasko4cb2d722020-04-23 13:49:16 +020053wget "${url}/archive/master.tar.gz" -O master.tar.gz
PavolVican384786e2017-07-12 15:31:20 +020054osc commit -m travis-update