travis_push_release.sh 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. # 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. zip -r "$TAG.zip" open62541.c open62541.h open62541.pdf README.md LICENSE AUTHORS
  30. rm open62541.c
  31. rm open62541.h
  32. rm open62541.pdf
  33. rm README.md
  34. rm LICENSE
  35. rm AUTHORS
  36. git add "$TAG.zip"
  37. echo "$TAG.zip" | cat - raw.txt > temp && mv temp raw.txt
  38. LINETOSTART=$((TAGSTOSAVE+1))
  39. #remove obsolete zips
  40. tail -n +"$LINETOSTART" raw.txt | xargs git rm --ignore-unmatch
  41. #remove obsolete zips from list
  42. head "-$TAGSTOSAVE" raw.txt > temp && mv temp raw.txt
  43. # quit releases
  44. cd ..
  45. git config --global user.email "open62541-travis-ci@users.noreply.github.com"
  46. git config --global user.name "Open62541 travis-ci"
  47. git config --global push.default simple
  48. git commit --allow-empty -am "added release files and updated releases webpage by travis-ci [ci skip]"
  49. git pull && git push https://$GITAUTH@github.com/open62541/open62541-www
  50. fi
  51. #quit open62541-www
  52. cd ..
  53. rm -rf open62541-www