2018-05-24 09:55:25 +00:00
#!/bin/bash
set -ex -o xtrace
BUILDPATH = ${ PWD }
BRANCH = "`git log --max-count=1 --date=short --abbrev=8 --pretty=format:" %cd_%h"`"
2018-11-20 12:02:29 +00:00
git clone --single-branch https://${ GH_TOKEN } @github.com/OpenSC/Nightly.git > /dev/null 2>& 1
2018-05-24 09:55:25 +00:00
cd Nightly
git checkout -b " ${ BRANCH } "
2020-04-14 16:18:26 +00:00
for file in ${ BUILDPATH } /win32/Output/OpenSC*.exe ${ BUILDPATH } /opensc*.tar.gz ${ BUILDPATH } /OpenSC*.dmg ${ BUILDPATH } /OpenSC*.msi ${ BUILDPATH } /OpenSC*.zip
2018-05-24 09:55:25 +00:00
do
if [ -f ${ file } ]
then
2020-10-19 16:17:23 +00:00
# github only allows a maximum file size of 50MB
MAX_MB_FILESIZE = 50
if [ $( du -m " $file " | cut -f 1) -ge $MAX_MB_FILESIZE ]
then
split -b ${ MAX_MB_FILESIZE } m ${ file } ` basename ${ file } ` .
else
cp ${ file } .
fi
git add ` basename ${ file } ` *
2018-05-24 09:55:25 +00:00
fi
done
git commit --message " $1 "
2019-10-17 22:41:10 +00:00
i = 0
while [ $i -le 10 ] && ! git push --quiet --set-upstream origin " ${ BRANCH } "
do
2018-05-24 09:55:25 +00:00
sleep $[ ( $RANDOM % 32 ) + 1 ] s
git pull --rebase origin " ${ BRANCH } "
2019-10-17 22:41:10 +00:00
i = $(( $i + 1 ))
done