travis_push_release.sh 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. cd releases
  15. if [ ! -e "$TAG.zip" ]; then
  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. zip -r "$TAG.zip" open62541.c open62541.h open62541.pdf
  27. rm open62541.c
  28. rm open62541.h
  29. rm open62541.pdf
  30. git add "$TAG.zip"
  31. echo "$TAG.zip" | cat - raw.txt > temp && mv temp raw.txt
  32. LINETOSTART=$((TAGSTOSAVE+1))
  33. #remove obsolete zips
  34. tail -n +"$LINETOSTART" raw.txt | xargs git rm --ignore-unmatch
  35. #remove obsolete zips from list
  36. head "-$TAGSTOSAVE" raw.txt > temp && mv temp raw.txt
  37. fi
  38. cd ..
  39. git config --global user.email "open62541-travis-ci@users.noreply.github.com"
  40. git config --global user.name "Open62541 travis-ci"
  41. git config --global push.default simple
  42. git commit -am "added release files and updated releases webpage by travis-ci [ci skip]"
  43. git pull && git push https://$GITAUTH@github.com/open62541/open62541-www
  44. cd ..
  45. rm -rf open62541-www