-
Notifications
You must be signed in to change notification settings - Fork 17
/
update_travis_mac.sh
executable file
·140 lines (118 loc) · 3.64 KB
/
update_travis_mac.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/bin/sh
##
## Travis-CI for MAC-OS-X auto-update script.
##
## Copyright (C) 2014 Assaf Gordon <[email protected]>
##
## This script is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## This script is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this script. If not, see <http://www.gnu.org/licenses/>.
##
##
## This script will:
## 1. branch from the current active branch,
## to a new (fixed nam) Travis-CI-Mac-OS branch (re-creating it if needed).
## 2. Create Travis-CI configuration for MAC-OS-X
## 3. Push the new branch to GitHub (optionally deleting previous branch)
## 4. Return to previously active branch
##
## New of branch to use (locally and remotely)
TRAVIS_MAC_BRANCH=travis_mac_osx
## New Travis-CI configuration, adapted for Mac-OS
NEW_TRAVIS_YML=\
"language: objective-c
compiler:
- clang
before_install:
- brew update
- brew install lcov
- brew install gettext
- brew install fftw
- brew install boost
- brew install cppunit
- brew install gsl
script:
- \"( git fetch --unshallow ; true )\"
- ls -l
- ./reconf
- ls -l
- git describe --always
- ./configure
- make
- make check VERBOSE=yes
after_script:
- cat ./tests/test-suite.log ; true"
die()
{
BASE=$(basename "$0")
echo "$BASE: error: $@" >&2
exit 1
}
##
## Stop if there are uncommited changes.
##
UNCOMMITTED=$(git status --porcelain -uno) \
|| die "failed to check for uncommited changes"
test -z "$UNCOMMITTED" \
|| die "there are uncommited changes in the current directory. Aborting."
## Get current branch name
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) \
|| die "failed to find current branch name"
test -z "$CURRENT_BRANCH" \
&& die "got empty current branch name"
test "$CURRENT_BRANCH" = "$TRAVIS_MAC_BRANCH" \
&& die "current branch is same as travis-ci branch"
##
## Delete local Travis-Mac branch (if any)
##
LOCAL=$(git branch --list "$TRAVIS_MAC_BRANCH") \
|| die "failed to check for local branch '$TRAVIS_MAC_BRANCH'"
if test -n "$LOCAL" ; then
# There's a local branch, delete it
git branch -q -D "$TRAVIS_MAC_BRANCH" \
|| die "failed to delete local branch '$TRAVIS_MAC_BRANCH'"
fi
##
## Delete remote Travis-Mac branch (if any)
##
REMOTE=$(git branch -r | grep "origin/$TRAVIS_MAC_BRANCH\$")
if test -n "$REMOTE" ; then
# Delete remote branch
git branch -q -r -D "origin/$TRAVIS_MAC_BRANCH" \
|| die "failed to delete remote branch 'origin/$TRAVIS_MAC_BRANCH'"
# Push (delete) remote branch on temote server (e.g. github)
git push -q origin ":$TRAVIS_MAC_BRANCH"
fi
##
## Create a new branch
##
git checkout -q -b "$TRAVIS_MAC_BRANCH" "$CURRENT_BRANCH" \
|| die "failed to checkout new branch"
##
## Write a new Travis-CI configuration file
##
echo "$NEW_TRAVIS_YML" > .travis.yml \
|| die "failed to update .travis.yml"
git add .travis.yml \
|| die "failed to git-add .travis.yml"
git commit -q -m "Auto-Updated Travis-CI for Mac configuration" \
|| die "failed to git-commit .travis.yml"
##
## Push new branch to remote server (e.g. github)
##
git push -q origin $TRAVIS_MAC_BRANCH:$TRAVIS_MAC_BRANCH \
|| die "failed to push branch '$TRAVIS_MAC_BRANCH' to remote server"
##
## Go back to master branch
##
git checkout -q "$CURRENT_BRANCH" \
|| die "failed to return to branch '$CURRENT_BRANCH'"