You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.2 KiB

2 months ago
  1. #!/usr/bin/env bash
  2. if [[ ${TASK} == "DEPLOY" && ${TRAVIS_BRANCH} == "master14" ]]; then
  3. BRANCH="deploy-`git rev-parse --short HEAD`"
  4. git checkout --orphan $BRANCH
  5. git add .gitignore CMakeLists.txt README.md
  6. git add cmake/ resources/ src/ test/
  7. git add -f lib/
  8. git add -f src/generated/
  9. git commit -m "Prebuild parser"
  10. git tag -fa deploy-latest -m "latest version"
  11. git remote add github https://${GH_TOKEN}@github.com/smtrat/carl-parser.git
  12. git push github $BRANCH --tags --force
  13. git config remote.github.fetch +refs/heads/*:refs/remotes/github/*
  14. git fetch --unshallow github
  15. for branch in `git for-each-ref --sort=committerdate --format='%(refname:short)'`
  16. do
  17. # Avoid deleting branches other than deploy-<commitid>
  18. if [[ ! "$branch" =~ ^github/deploy-[0-9a-f]+$ ]]; then
  19. continue
  20. fi
  21. # Avoid deleting branches referenced by tags
  22. tags=`git log --oneline --decorate $branch | grep "tag:"`
  23. if [[ ! -z "$tags" ]]; then
  24. continue
  25. fi
  26. # Avoid deleting branches less than a week old
  27. now=`date +%s`
  28. lastcommit=`git log --pretty=format:'%at' -1 $branch`
  29. days=$(((now-lastcommit)/3600/24))
  30. if [ "$days" -lt 7 ]; then
  31. continue
  32. fi
  33. echo "Deleting $branch..."
  34. git push github --delete ${branch#github/}
  35. done
  36. fi