blob: 8c7b60bded1d8ebe2f2164c4218650c23453d356 [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
Andreas Wundsam77d04252013-11-20 11:02:45 -080012ARTIFACT_REPO=$(mktemp -d --tmpdir "push-artifacts-repo.XXXXXXX")
Andreas Wundsamd0b06f42013-11-19 17:18:14 -080013
14git clone ${ARTIFACT_REPO_URL} ${ARTIFACT_REPO}
Andreas Wundsam77d04252013-11-20 11:02:45 -080015find ${ARTIFACT_REPO} -mindepth 1 -maxdepth 1 -type d \! -name '.*' -print0 | xargs -0 rm -r
Andreas Wundsamd0b06f42013-11-19 17:18:14 -080016make LOXI_OUTPUT_DIR=${ARTIFACT_REPO} clean all
17
Andreas Wundsamd0b06f42013-11-19 17:18:14 -080018loxi_head=$(git rev-parse HEAD)
19last_loxi_log=$(git log --format=oneline -1)
Andreas Wundsam77d04252013-11-20 11:02:45 -080020git_log_file=$(mktemp --tmpdir "git-log-file.XXXXXXX")
21
Andreas Wundsam71178d12013-11-20 11:38:38 -080022last_loxi_revision=""
23
Andreas Wundsam77d04252013-11-20 11:02:45 -080024if [[ -e "${ARTIFACT_REPO}/loxi-revision" ]]; then
25 last_loxi_revision=$(cat "${ARTIFACT_REPO}/loxi-revision" | cut -d ' ' -f 1)
Andreas Wundsam71178d12013-11-20 11:38:38 -080026 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
30fi
31
32if [[ $last_loxi_revision ]]; then
Andreas Wundsamd0b06f42013-11-19 17:18:14 -080033 echo "Last loxi revision committed: $last_loxi_revision"
Andreas Wundsam71178d12013-11-20 11:38:38 -080034 git log $last_loxi_revision..${loxi_head} >>$git_log_file
Andreas Wundsamd0b06f42013-11-19 17:18:14 -080035 loxi_github_url="https://github.com/floodlight/loxigen/compare/${last_loxi_revision}...${loxi_head}"
36else
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}"
40fi
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 Wundsam77d04252013-11-20 11:02:45 -080052 echo "Loxigen Head commit floodlight/loxigen@${loxi_head}"
Andreas Wundsamd0b06f42013-11-19 17:18:14 -080053 cat $git_log_file
54 ) | git commit --file=-
55
56 git tag -a -f "loxi/${loxi_head}" -m "Tag Loxigen Revision ${loxi_head}"
Andreas Wundsam025ed0d2013-11-27 13:01:28 -080057 git push --tags
Andreas Wundsamd0b06f42013-11-19 17:18:14 -080058 git push
59)
60
61rm -rf ${ARTIFACT_REPO}