blob: ec81d62f929a728d23770695d48c8e7af999aab2 [file] [log] [blame]
Andreas Wundsam77d04252013-11-20 11:02:45 -08001#!/bin/bash -eu
Andreas Wundsamd0b06f42013-11-19 17:18:14 -08002
3# Push the loxigen artifacts to a dedicated git repository,
4# along with a nice commit message and a tag
5
6ARTIFACT_REPO_URL="$1"
7if [[ ! $ARTIFACT_REPO_URL ]]; then
8 echo "Call syntax: $0 <artifact_repo_url>" >&2
9 exit 1
10fi
11
Rich Lane7c5b6a62014-12-03 12:49:04 -080012ARTIFACT_REPO_BRANCH=${2-master}
13
Andreas Wundsam77d04252013-11-20 11:02:45 -080014ARTIFACT_REPO=$(mktemp -d --tmpdir "push-artifacts-repo.XXXXXXX")
Andreas Wundsamd0b06f42013-11-19 17:18:14 -080015
Rich Lane7c5b6a62014-12-03 12:49:04 -080016git clone ${ARTIFACT_REPO_URL} ${ARTIFACT_REPO} -b ${ARTIFACT_REPO_BRANCH}
Andreas Wundsam77d04252013-11-20 11:02:45 -080017find ${ARTIFACT_REPO} -mindepth 1 -maxdepth 1 -type d \! -name '.*' -print0 | xargs -0 rm -r
Andreas Wundsamd0b06f42013-11-19 17:18:14 -080018make LOXI_OUTPUT_DIR=${ARTIFACT_REPO} clean all
19
Andreas Wundsamd0b06f42013-11-19 17:18:14 -080020loxi_head=$(git rev-parse HEAD)
21last_loxi_log=$(git log --format=oneline -1)
Andreas Wundsam77d04252013-11-20 11:02:45 -080022git_log_file=$(mktemp --tmpdir "git-log-file.XXXXXXX")
23
Andreas Wundsam71178d12013-11-20 11:38:38 -080024last_loxi_revision=""
25
Andreas Wundsam77d04252013-11-20 11:02:45 -080026if [[ -e "${ARTIFACT_REPO}/loxi-revision" ]]; then
27 last_loxi_revision=$(cat "${ARTIFACT_REPO}/loxi-revision" | cut -d ' ' -f 1)
Andreas Wundsam71178d12013-11-20 11:38:38 -080028 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
32fi
33
34if [[ $last_loxi_revision ]]; then
Andreas Wundsamd0b06f42013-11-19 17:18:14 -080035 echo "Last loxi revision committed: $last_loxi_revision"
Andreas Wundsam71178d12013-11-20 11:38:38 -080036 git log $last_loxi_revision..${loxi_head} >>$git_log_file
Andreas Wundsamd0b06f42013-11-19 17:18:14 -080037 loxi_github_url="https://github.com/floodlight/loxigen/compare/${last_loxi_revision}...${loxi_head}"
38else
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}"
42fi
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 Wundsam77d04252013-11-20 11:02:45 -080054 echo "Loxigen Head commit floodlight/loxigen@${loxi_head}"
Andreas Wundsamd0b06f42013-11-19 17:18:14 -080055 cat $git_log_file
56 ) | git commit --file=-
57
58 git tag -a -f "loxi/${loxi_head}" -m "Tag Loxigen Revision ${loxi_head}"
Andreas Wundsam025ed0d2013-11-27 13:01:28 -080059 git push --tags
Rich Lane7c5b6a62014-12-03 12:49:04 -080060 git push origin HEAD
Andreas Wundsamd0b06f42013-11-19 17:18:14 -080061)
62
63rm -rf ${ARTIFACT_REPO}