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 | |
Andreas Wundsam | 71178d1 | 2013-11-20 11:38:38 -0800 | [diff] [blame] | 22 | last_loxi_revision="" |
| 23 | |
Andreas Wundsam | 77d0425 | 2013-11-20 11:02:45 -0800 | [diff] [blame] | 24 | if [[ -e "${ARTIFACT_REPO}/loxi-revision" ]]; then |
| 25 | last_loxi_revision=$(cat "${ARTIFACT_REPO}/loxi-revision" | cut -d ' ' -f 1) |
Andreas Wundsam | 71178d1 | 2013-11-20 11:38:38 -0800 | [diff] [blame] | 26 | if [[ $(git cat-file -t "$last_loxi_revision" 2>/dev/null) != "commit" ]]; then |
| 27 | echo "Last loxi revision ${last_loxi_revision} specified in ${ARTIFACT_REPO_URL}/loxi-revision not found in loxigen repo" |
| 28 | last_loxi_revision="" |
| 29 | fi |
| 30 | fi |
| 31 | |
| 32 | if [[ $last_loxi_revision ]]; then |
Andreas Wundsam | d0b06f4 | 2013-11-19 17:18:14 -0800 | [diff] [blame] | 33 | echo "Last loxi revision committed: $last_loxi_revision" |
Andreas Wundsam | 71178d1 | 2013-11-20 11:38:38 -0800 | [diff] [blame] | 34 | git log $last_loxi_revision..${loxi_head} >>$git_log_file |
Andreas Wundsam | d0b06f4 | 2013-11-19 17:18:14 -0800 | [diff] [blame] | 35 | loxi_github_url="https://github.com/floodlight/loxigen/compare/${last_loxi_revision}...${loxi_head}" |
| 36 | else |
| 37 | echo "No Previous loxi revision info found" |
| 38 | git log -1 HEAD >>$git_log_file |
| 39 | loxi_github_url="https://github.com/floodlight/loxigen/commit/${loxi_head}" |
| 40 | fi |
| 41 | |
| 42 | |
| 43 | ( |
| 44 | set -xe |
| 45 | cd $ARTIFACT_REPO |
| 46 | echo $last_loxi_log >loxi-revision |
| 47 | git add -A |
| 48 | |
| 49 | ( |
| 50 | echo "Artifacts from ${loxi_github_url}" |
| 51 | echo |
Andreas Wundsam | 77d0425 | 2013-11-20 11:02:45 -0800 | [diff] [blame] | 52 | echo "Loxigen Head commit floodlight/loxigen@${loxi_head}" |
Andreas Wundsam | d0b06f4 | 2013-11-19 17:18:14 -0800 | [diff] [blame] | 53 | cat $git_log_file |
| 54 | ) | git commit --file=- |
| 55 | |
| 56 | git tag -a -f "loxi/${loxi_head}" -m "Tag Loxigen Revision ${loxi_head}" |
Andreas Wundsam | 025ed0d | 2013-11-27 13:01:28 -0800 | [diff] [blame] | 57 | git push --tags |
Andreas Wundsam | d0b06f4 | 2013-11-19 17:18:14 -0800 | [diff] [blame] | 58 | git push |
| 59 | ) |
| 60 | |
| 61 | rm -rf ${ARTIFACT_REPO} |