Andreas Wundsam | 77d0425 | 2013-11-20 11:02:45 -0800 | [diff] [blame^] | 1 | #!/bin/bash -eu |
Andreas Wundsam | d0b06f4 | 2013-11-19 17:18:14 -0800 | [diff] [blame] | 2 | |
| 3 | # Push the loxigen artifacts to a dedicated git repository, |
| 4 | # along with a nice commit message and a tag |
| 5 | |
| 6 | ARTIFACT_REPO_URL="$1" |
| 7 | if [[ ! $ARTIFACT_REPO_URL ]]; then |
| 8 | echo "Call syntax: $0 <artifact_repo_url>" >&2 |
| 9 | exit 1 |
| 10 | fi |
| 11 | |
Andreas Wundsam | 77d0425 | 2013-11-20 11:02:45 -0800 | [diff] [blame^] | 12 | ARTIFACT_REPO=$(mktemp -d --tmpdir "push-artifacts-repo.XXXXXXX") |
Andreas Wundsam | d0b06f4 | 2013-11-19 17:18:14 -0800 | [diff] [blame] | 13 | |
| 14 | git clone ${ARTIFACT_REPO_URL} ${ARTIFACT_REPO} |
Andreas Wundsam | 77d0425 | 2013-11-20 11:02:45 -0800 | [diff] [blame^] | 15 | find ${ARTIFACT_REPO} -mindepth 1 -maxdepth 1 -type d \! -name '.*' -print0 | xargs -0 rm -r |
Andreas Wundsam | d0b06f4 | 2013-11-19 17:18:14 -0800 | [diff] [blame] | 16 | make LOXI_OUTPUT_DIR=${ARTIFACT_REPO} clean all |
| 17 | |
Andreas Wundsam | d0b06f4 | 2013-11-19 17:18:14 -0800 | [diff] [blame] | 18 | loxi_head=$(git rev-parse HEAD) |
| 19 | last_loxi_log=$(git log --format=oneline -1) |
Andreas Wundsam | 77d0425 | 2013-11-20 11:02:45 -0800 | [diff] [blame^] | 20 | git_log_file=$(mktemp --tmpdir "git-log-file.XXXXXXX") |
| 21 | |
| 22 | if [[ -e "${ARTIFACT_REPO}/loxi-revision" ]]; then |
| 23 | last_loxi_revision=$(cat "${ARTIFACT_REPO}/loxi-revision" | cut -d ' ' -f 1) |
Andreas Wundsam | d0b06f4 | 2013-11-19 17:18:14 -0800 | [diff] [blame] | 24 | echo "Last loxi revision committed: $last_loxi_revision" |
| 25 | git log $last_loxi_revision..HEAD >>$git_log_file |
| 26 | loxi_github_url="https://github.com/floodlight/loxigen/compare/${last_loxi_revision}...${loxi_head}" |
| 27 | else |
| 28 | echo "No Previous loxi revision info found" |
| 29 | git log -1 HEAD >>$git_log_file |
| 30 | loxi_github_url="https://github.com/floodlight/loxigen/commit/${loxi_head}" |
| 31 | fi |
| 32 | |
| 33 | |
| 34 | ( |
| 35 | set -xe |
| 36 | cd $ARTIFACT_REPO |
| 37 | echo $last_loxi_log >loxi-revision |
| 38 | git add -A |
| 39 | |
| 40 | ( |
| 41 | echo "Artifacts from ${loxi_github_url}" |
| 42 | echo |
Andreas Wundsam | 77d0425 | 2013-11-20 11:02:45 -0800 | [diff] [blame^] | 43 | echo "Loxigen Head commit floodlight/loxigen@${loxi_head}" |
Andreas Wundsam | d0b06f4 | 2013-11-19 17:18:14 -0800 | [diff] [blame] | 44 | cat $git_log_file |
| 45 | ) | git commit --file=- |
| 46 | |
| 47 | git tag -a -f "loxi/${loxi_head}" -m "Tag Loxigen Revision ${loxi_head}" |
| 48 | git push |
| 49 | ) |
| 50 | |
| 51 | rm -rf ${ARTIFACT_REPO} |