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. cd releases
  11. if [ ! -e "$TAG.zip" ]; then
  12. #add the first line
  13. 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
  14. #keep top lines only
  15. head "-$TAGSTOSAVE" rawtable.txt > temp && mv temp rawtable.txt
  16. #compose the index file
  17. cat head.txt rawtable.txt foot.txt > index.html
  18. #create a zip for single-file release and copy the files
  19. cp ../../../open62541.c .
  20. cp ../../../open62541.h .
  21. cp ../../../doc_latex/open62541.pdf .
  22. zip -r "$TAG.zip" open62541.c open62541.h open62541.pdf
  23. rm open62541.c
  24. rm open62541.h
  25. rm open62541.pdf
  26. git add "$TAG.zip"
  27. echo "$TAG.zip" | cat - raw.txt > temp && mv temp raw.txt
  28. LINETOSTART=$((TAGSTOSAVE+1))
  29. #remove obsolete zips
  30. tail -n +"$LINETOSTART" raw.txt | xargs git rm --ignore-unmatch
  31. #remove obsolete zips from list
  32. head "-$TAGSTOSAVE" raw.txt > temp && mv temp raw.txt
  33. fi
  34. cd ..
  35. git config --global user.email "open62541-travis-ci@users.noreply.github.com"
  36. git config --global user.name "Open62541 travis-ci"
  37. git config --global push.default simple
  38. git commit -am "added release files and updated releases webpage by travis-ci [ci skip]"
  39. git push https://$GITAUTH@github.com/open62541/open62541-www
  40. cd ..
  41. rm -rf open62541-www