travis_push_release.sh 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/bin/bash
  2. set -ev
  3. TAGSTOSAVE=50
  4. TAG="$(git rev-parse --short=10 HEAD)"
  5. BRANCH="$(git log --pretty=format:"%d" --date=iso --abbrev=10 --all -1)"
  6. DATE="$(git log --pretty=format:"%ad" --date=iso --abbrev=10 --all -1)"
  7. COMMENT="$(git log --pretty=format:"%s" --date=iso --abbrev=10 --all -1)"
  8. git clone --depth=5 -b gh-pages https://$GITAUTH@github.com/open62541/open62541-www
  9. cd open62541-www
  10. #hanndle releases
  11. cd releases
  12. if [ ! -e "$TAG.zip" ]; then
  13. #add the first line
  14. echo "<tr><td><a href='./$TAG.zip'>$TAG</a></td><td>$BRANCH</td><td>$DATE</td><td>$COMMENT</td></tr>" | cat - rawtable.txt > temp && mv temp rawtable.txt
  15. #keep top lines only
  16. head "-$TAGSTOSAVE" rawtable.txt > temp && mv temp rawtable.txt
  17. #compose the index file
  18. cat head.txt rawtable.txt foot.txt > index.html
  19. #create a zip for single-file release and copy the files
  20. cp ../../../open62541.c .
  21. cp ../../../open62541.h .
  22. cp ../../../doc_latex/open62541.pdf .
  23. zip -r "$TAG.zip" open62541.c open62541.h open62541.pdf
  24. rm open62541.c
  25. rm open62541.h
  26. rm open62541.pdf
  27. git add "$TAG.zip"
  28. echo "$TAG.zip" | cat - raw.txt > temp && mv temp raw.txt
  29. LINETOSTART=$((TAGSTOSAVE+1))
  30. #remove obsolete zips
  31. tail -n +"$LINETOSTART" raw.txt | xargs git rm --ignore-unmatch
  32. #remove obsolete zips from list
  33. head "-$TAGSTOSAVE" raw.txt > temp && mv temp raw.txt
  34. fi
  35. cd ..
  36. git config --global user.email "open62541-travis-ci@users.noreply.github.com"
  37. git config --global user.name "Open62541 travis-ci"
  38. git config --global push.default simple
  39. git commit -am "added release files and updated releases webpage by travis-ci [ci skip]"
  40. git push https://$GITAUTH@github.com/open62541/open62541-www
  41. cd ..
  42. rm -rf open62541-www