travis_push_release.sh 1.6 KB

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