travis_push_release.sh 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/bin/bash
  2. set -e
  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. # The encrypted key is not available in pull requests from forks
  9. if [ -z "$GITAUTH" ]; then
  10. exit 0
  11. fi
  12. git clone --depth=5 -b gh-pages https://$GITAUTH@github.com/open62541/open62541-www
  13. cd open62541-www
  14. if [ ! -e "releases/$TAG.zip" ]; then
  15. cd releases
  16. #add the first line
  17. 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
  18. #keep top lines only
  19. head "-$TAGSTOSAVE" rawtable.txt > temp && mv temp rawtable.txt
  20. #compose the index file
  21. cat head.txt rawtable.txt foot.txt > index.html
  22. #create a zip for single-file release and copy the files
  23. cp ../../../open62541.c .
  24. cp ../../../open62541.h .
  25. cp ../../../doc_latex/open62541.pdf .
  26. cp ./../../README.md .
  27. cp ./../../LICENSE .
  28. cp ./../../AUTHORS .
  29. cp ./../../libopen62541*.deb .
  30. zip -r "$TAG.zip" open62541.c open62541.h open62541.pdf README.md LICENSE AUTHORS open62541*.deb
  31. rm open62541.c
  32. rm open62541.h
  33. rm open62541.pdf
  34. rm README.md
  35. rm LICENSE
  36. rm AUTHORS
  37. rm libopen62541*.deb
  38. git add "$TAG.zip"
  39. echo "$TAG.zip" | cat - raw.txt > temp && mv temp raw.txt
  40. LINETOSTART=$((TAGSTOSAVE+1))
  41. #remove obsolete zips
  42. tail -n +"$LINETOSTART" raw.txt | xargs git rm --ignore-unmatch
  43. #remove obsolete zips from list
  44. head "-$TAGSTOSAVE" raw.txt > temp && mv temp raw.txt
  45. # quit releases
  46. cd ..
  47. git config --global user.email "open62541-travis-ci@users.noreply.github.com"
  48. git config --global user.name "Open62541 travis-ci"
  49. git config --global push.default simple
  50. git commit --allow-empty -am "added release files and updated releases webpage by travis-ci [ci skip]"
  51. git pull && git push https://$GITAUTH@github.com/open62541/open62541-www
  52. fi
  53. #quit open62541-www
  54. cd ..
  55. rm -rf open62541-www