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 | |
Rich Lane | 7c5b6a6 | 2014-12-03 12:49:04 -0800 | [diff] [blame] | 12 | ARTIFACT_REPO_BRANCH=${2-master} |
| 13 | |
Andreas Wundsam | 77d0425 | 2013-11-20 11:02:45 -0800 | [diff] [blame] | 14 | ARTIFACT_REPO=$(mktemp -d --tmpdir "push-artifacts-repo.XXXXXXX") |
Andreas Wundsam | d0b06f4 | 2013-11-19 17:18:14 -0800 | [diff] [blame] | 15 | |
Rich Lane | 7c5b6a6 | 2014-12-03 12:49:04 -0800 | [diff] [blame] | 16 | git clone ${ARTIFACT_REPO_URL} ${ARTIFACT_REPO} -b ${ARTIFACT_REPO_BRANCH} |
Andreas Wundsam | 77d0425 | 2013-11-20 11:02:45 -0800 | [diff] [blame] | 17 | 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] | 18 | make LOXI_OUTPUT_DIR=${ARTIFACT_REPO} clean all |
| 19 | |
Andreas Wundsam | d0b06f4 | 2013-11-19 17:18:14 -0800 | [diff] [blame] | 20 | loxi_head=$(git rev-parse HEAD) |
| 21 | last_loxi_log=$(git log --format=oneline -1) |
Andreas Wundsam | 77d0425 | 2013-11-20 11:02:45 -0800 | [diff] [blame] | 22 | git_log_file=$(mktemp --tmpdir "git-log-file.XXXXXXX") |
| 23 | |
Andreas Wundsam | 71178d1 | 2013-11-20 11:38:38 -0800 | [diff] [blame] | 24 | last_loxi_revision="" |
| 25 | |
Andreas Wundsam | 77d0425 | 2013-11-20 11:02:45 -0800 | [diff] [blame] | 26 | if [[ -e "${ARTIFACT_REPO}/loxi-revision" ]]; then |
| 27 | last_loxi_revision=$(cat "${ARTIFACT_REPO}/loxi-revision" | cut -d ' ' -f 1) |
Andreas Wundsam | 71178d1 | 2013-11-20 11:38:38 -0800 | [diff] [blame] | 28 | if [[ $(git cat-file -t "$last_loxi_revision" 2>/dev/null) != "commit" ]]; then |
| 29 | echo "Last loxi revision ${last_loxi_revision} specified in ${ARTIFACT_REPO_URL}/loxi-revision not found in loxigen repo" |
| 30 | last_loxi_revision="" |
| 31 | fi |
| 32 | fi |
| 33 | |
| 34 | if [[ $last_loxi_revision ]]; then |
Andreas Wundsam | d0b06f4 | 2013-11-19 17:18:14 -0800 | [diff] [blame] | 35 | echo "Last loxi revision committed: $last_loxi_revision" |
Andreas Wundsam | 71178d1 | 2013-11-20 11:38:38 -0800 | [diff] [blame] | 36 | git log $last_loxi_revision..${loxi_head} >>$git_log_file |
Andreas Wundsam | d0b06f4 | 2013-11-19 17:18:14 -0800 | [diff] [blame] | 37 | loxi_github_url="https://github.com/floodlight/loxigen/compare/${last_loxi_revision}...${loxi_head}" |
| 38 | else |
| 39 | echo "No Previous loxi revision info found" |
| 40 | git log -1 HEAD >>$git_log_file |
| 41 | loxi_github_url="https://github.com/floodlight/loxigen/commit/${loxi_head}" |
| 42 | fi |
| 43 | |
| 44 | |
| 45 | ( |
| 46 | set -xe |
| 47 | cd $ARTIFACT_REPO |
| 48 | echo $last_loxi_log >loxi-revision |
| 49 | git add -A |
| 50 | |
| 51 | ( |
| 52 | echo "Artifacts from ${loxi_github_url}" |
| 53 | echo |
Andreas Wundsam | 77d0425 | 2013-11-20 11:02:45 -0800 | [diff] [blame] | 54 | echo "Loxigen Head commit floodlight/loxigen@${loxi_head}" |
Andreas Wundsam | d0b06f4 | 2013-11-19 17:18:14 -0800 | [diff] [blame] | 55 | cat $git_log_file |
| 56 | ) | git commit --file=- |
| 57 | |
| 58 | 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] | 59 | git push --tags |
Rich Lane | 7c5b6a6 | 2014-12-03 12:49:04 -0800 | [diff] [blame] | 60 | git push origin HEAD |
Andreas Wundsam | d0b06f4 | 2013-11-19 17:18:14 -0800 | [diff] [blame] | 61 | ) |
| 62 | |
| 63 | rm -rf ${ARTIFACT_REPO} |