blob: ae7ace68f70c274bcc116e864235a0bbd5b991c3 [file] [log] [blame]
Murat Parlakisikf95672c2016-12-05 00:53:17 -08001#!/bin/bash -eux
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}
Murat Parlakisikf95672c2016-12-05 00:53:17 -080013ARTIFACT_TARGET_BRANCH=${3-master}
14
15MAKE=${MAKE-make}
Rich Lane7c5b6a62014-12-03 12:49:04 -080016
Andreas Wundsam77d04252013-11-20 11:02:45 -080017ARTIFACT_REPO=$(mktemp -d --tmpdir "push-artifacts-repo.XXXXXXX")
Andreas Wundsamd0b06f42013-11-19 17:18:14 -080018
Rich Lane7c5b6a62014-12-03 12:49:04 -080019git clone ${ARTIFACT_REPO_URL} ${ARTIFACT_REPO} -b ${ARTIFACT_REPO_BRANCH}
Andreas Wundsamd0b06f42013-11-19 17:18:14 -080020
Murat Parlakisikf95672c2016-12-05 00:53:17 -080021find ${ARTIFACT_REPO} -mindepth 1 -maxdepth 1 -type d \! -name '.*' -print0 | xargs -0 rm -r
22${MAKE} LOXI_OUTPUT_DIR=${ARTIFACT_REPO} clean all
23
24loxi_branch=$(git rev-parse --abbrev-ref HEAD)
Andreas Wundsamd0b06f42013-11-19 17:18:14 -080025loxi_head=$(git rev-parse HEAD)
26last_loxi_log=$(git log --format=oneline -1)
Andreas Wundsam77d04252013-11-20 11:02:45 -080027git_log_file=$(mktemp --tmpdir "git-log-file.XXXXXXX")
28
Andreas Wundsam71178d12013-11-20 11:38:38 -080029last_loxi_revision=""
30
Andreas Wundsam77d04252013-11-20 11:02:45 -080031if [[ -e "${ARTIFACT_REPO}/loxi-revision" ]]; then
32 last_loxi_revision=$(cat "${ARTIFACT_REPO}/loxi-revision" | cut -d ' ' -f 1)
Andreas Wundsam71178d12013-11-20 11:38:38 -080033 if [[ $(git cat-file -t "$last_loxi_revision" 2>/dev/null) != "commit" ]]; then
34 echo "Last loxi revision ${last_loxi_revision} specified in ${ARTIFACT_REPO_URL}/loxi-revision not found in loxigen repo"
35 last_loxi_revision=""
36 fi
37fi
38
39if [[ $last_loxi_revision ]]; then
Andreas Wundsamd0b06f42013-11-19 17:18:14 -080040 echo "Last loxi revision committed: $last_loxi_revision"
Andreas Wundsam71178d12013-11-20 11:38:38 -080041 git log $last_loxi_revision..${loxi_head} >>$git_log_file
Andreas Wundsamd0b06f42013-11-19 17:18:14 -080042 loxi_github_url="https://github.com/floodlight/loxigen/compare/${last_loxi_revision}...${loxi_head}"
43else
44 echo "No Previous loxi revision info found"
45 git log -1 HEAD >>$git_log_file
46 loxi_github_url="https://github.com/floodlight/loxigen/commit/${loxi_head}"
47fi
48
49
50(
51 set -xe
52 cd $ARTIFACT_REPO
53 echo $last_loxi_log >loxi-revision
54 git add -A
55
56 (
Murat Parlakisikf95672c2016-12-05 00:53:17 -080057 echo "Artifacts from ${loxi_github_url} (Branch ${loxi_branch})"
Andreas Wundsamd0b06f42013-11-19 17:18:14 -080058 echo
Andreas Wundsam77d04252013-11-20 11:02:45 -080059 echo "Loxigen Head commit floodlight/loxigen@${loxi_head}"
Andreas Wundsamd0b06f42013-11-19 17:18:14 -080060 cat $git_log_file
61 ) | git commit --file=-
62
63 git tag -a -f "loxi/${loxi_head}" -m "Tag Loxigen Revision ${loxi_head}"
Murat Parlakisikf95672c2016-12-05 00:53:17 -080064 git push --tags -f
65 if [[ $ARTIFACT_TARGET_BRANCH != $ARTIFACT_REPO_BRANCH ]]; then
66 git push -f origin HEAD:${ARTIFACT_TARGET_BRANCH}
67 else
68 git push origin HEAD
69 fi
Andreas Wundsamd0b06f42013-11-19 17:18:14 -080070)
71
72rm -rf ${ARTIFACT_REPO}