travis_push_release.sh 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/bash
  2. TAGSTOSAVE=50
  3. TAG="$(git rev-parse --short=10 HEAD)"
  4. BRANCH="$(git log --pretty=format:"%d" --date=iso --abbrev=10 --all -1)"
  5. DATE="$(git log --pretty=format:"%ad" --date=iso --abbrev=10 --all -1)"
  6. COMMENT="$(git log --pretty=format:"%s" --date=iso --abbrev=10 --all -1)"
  7. git clone --depth=5 -b gh-pages https://$GITAUTH@github.com/open62541/open62541-www
  8. cd open62541-www
  9. #hanndle releases
  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. zip -r "$TAG.zip" open62541.c open62541.h
  22. rm open62541.c
  23. rm open62541.h
  24. git add "$TAG.zip"
  25. echo "$TAG.zip" | cat - raw.txt > temp && mv temp raw.txt
  26. LINETOSTART=$((TAGSTOSAVE+1))
  27. #remove obsolete zips
  28. tail -n +"$LINETOSTART" raw.txt | xargs git rm
  29. #remove obsolete zips from list
  30. head "-$TAGSTOSAVE" raw.txt > temp && mv temp raw.txt
  31. fi
  32. cd ..
  33. git config --global user.email "open62541-travis-ci@users.noreply.github.com"
  34. git config --global user.name "Open62541 travis-ci"
  35. git config --global push.default simple
  36. git commit -am "added release files and updated releases webpage by travis-ci [ci skip]"
  37. git push https://$GITAUTH@github.com/open62541/open62541-www
  38. cd ..
  39. rm -rf open62541-www