Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 175 lines (142 sloc) 4.899 kB
7c94e65 @convissor Expand what the scripts do and break them up into three steps/scripts.
convissor authored
1 #! /bin/bash
2
baefa88 @convissor Remove quotes in if expressions.
convissor authored
3 if [ -z $2 ] ; then
7c94e65 @convissor Expand what the scripts do and break them up into three steps/scripts.
convissor authored
4 echo "Creates a repository on GitHub and pushes the PEAR package to it."
5 echo ""
6 echo "cd into the package's directory, then call this script."
7 echo ""
7fe05a7 @convissor Make password optional and ask for it interactively if required.
convissor authored
8 echo "Usage: ../2-to-github.sh package username [password]"
7c94e65 @convissor Expand what the scripts do and break them up into three steps/scripts.
convissor authored
9 echo ""
10 echo " package: the PEAR package name"
11 echo " username: your GitHub user name"
7fe05a7 @convissor Make password optional and ask for it interactively if required.
convissor authored
12 echo " password: your GitHub website password (optional). If omitted,"
13 echo " you will be prompted for it if actions require it."
7c94e65 @convissor Expand what the scripts do and break them up into three steps/scripts.
convissor authored
14 echo ""
15 exit 1
16 fi
17
18 package=$1
19 user=$2
20 api=https://api.github.com
21
7ac84f6 @CloCkWeRX Oops, merge error
CloCkWeRX authored
22
7c94e65 @convissor Expand what the scripts do and break them up into three steps/scripts.
convissor authored
23 # Quietly check: are the dependencies installed?
24
25 tmp=`curl --version`
baefa88 @convissor Remove quotes in if expressions.
convissor authored
26 if [ $? -ne 0 ] ; then
7c94e65 @convissor Expand what the scripts do and break them up into three steps/scripts.
convissor authored
27 echo "ERROR: curl must be installed and in your PATH."
28 exit 1
29 fi
30
31 tmp=`svn --version`
baefa88 @convissor Remove quotes in if expressions.
convissor authored
32 if [ $? -ne 0 ] ; then
7c94e65 @convissor Expand what the scripts do and break them up into three steps/scripts.
convissor authored
33 echo "ERROR: svn must be installed and in your PATH."
34 exit 1
35 fi
36
37 tmp=`git --version`
baefa88 @convissor Remove quotes in if expressions.
convissor authored
38 if [ $? -ne 0 ] ; then
7c94e65 @convissor Expand what the scripts do and break them up into three steps/scripts.
convissor authored
39 echo "ERROR: git must be installed and in your PATH."
40 exit 1
41 fi
42
43
44 # Is this script being called from a valid location?
45
7f616ec @convissor Remove regex from pwd test to keep cygwin happy.
convissor authored
46 if [[ `basename $PWD` != $package ]] ; then
7c94e65 @convissor Expand what the scripts do and break them up into three steps/scripts.
convissor authored
47 echo "ERROR: cd to the $package directory before calling this script."
48 exit 1
49 fi
50
7c5e76e @convissor Yes, I am a pedant: adjust if/then coding style.
convissor authored
51 if [ ! -d .git ] ; then
7c94e65 @convissor Expand what the scripts do and break them up into three steps/scripts.
convissor authored
52 echo "ERROR: the $package directory is not a git repository."
53 exit 1
54 fi
55
56
14fd0d0 @convissor Call api to create hook that emails pear-cvs list.
convissor authored
57 # Obtain the GitHub website password.
58
59 if [ $3 ] ; then
60 pass=$3
61 echo ""
62 echo "NOTICE: password is now optional."
63 echo "This script will ask for it interactively, if it is required."
64 echo ""
65 else
66 echo ""
7ac84f6 @CloCkWeRX Oops, merge error
CloCkWeRX authored
67 echo -n "What is your GitHub website password? "
14fd0d0 @convissor Call api to create hook that emails pear-cvs list.
convissor authored
68 read -e -s pass
69 echo ""
70 fi
71
72 if [ -z $pass ] ; then
73 echo "ERROR: actions taken require a password, but none was provided."
74 exit 1
75 fi
76
77
fe92933 @convissor Manually use curl proxy parameter because some platforms are ignoring…
convissor authored
78 # Workaround for some curl installs not acknowledging proxy.
79
80 if [ $HTTPS_PROXY ] ; then
81 curl_args="--proxy $HTTPS_PROXY"
82 elif [ $http_proxy ] ; then
83 curl_args="--proxy $http_proxy"
84 else
85 curl_args=
86 fi
87
88
7c94e65 @convissor Expand what the scripts do and break them up into three steps/scripts.
convissor authored
89 # Does the repository exist on GitHub?
90
5c9857a @CloCkWeRX Add support for proxy, when curl doesn't listen to http_proxy, and an…
CloCkWeRX authored
91 response=`curl $curl_args -s -S $api/repos/pear/$package`
baefa88 @convissor Remove quotes in if expressions.
convissor authored
92 if [ $? -ne 0 ] ; then
7c94e65 @convissor Expand what the scripts do and break them up into three steps/scripts.
convissor authored
93 echo "ERROR: curl had problem calling GitHub search API."
94 exit 1
1b705d2 @convissor Change regex to wildcard in tests to make cygwin happy.
convissor authored
95 elif [[ $response == *'"Not Found"'* ]] ; then
7d2b312 @convissor Enable automatic repo creation (thanks to GitHub crew for improving t…
convissor authored
96 # Repository not there yet; create it in the pear-dev team.
7c94e65 @convissor Expand what the scripts do and break them up into three steps/scripts.
convissor authored
97
7d2b312 @convissor Enable automatic repo creation (thanks to GitHub crew for improving t…
convissor authored
98 post="{\"name\":\"$package\", \"homepage\":\"http://pear.php.net/package/$package\", \"team_id\":83068, \"has_issues\":false, \"has_wiki\":false}"
fe92933 @convissor Manually use curl proxy parameter because some platforms are ignoring…
convissor authored
99 response=`curl $curl_args -s -S -u "$user:$pass" -d "$post" $api/orgs/pear/repos`
baefa88 @convissor Remove quotes in if expressions.
convissor authored
100 if [ $? -ne 0 ] ; then
7c94e65 @convissor Expand what the scripts do and break them up into three steps/scripts.
convissor authored
101 echo "ERROR: curl had problem calling GitHub create API."
102 exit 1
1b705d2 @convissor Change regex to wildcard in tests to make cygwin happy.
convissor authored
103 elif [[ $response == *'"message"'* ]] ; then
7c94e65 @convissor Expand what the scripts do and break them up into three steps/scripts.
convissor authored
104 # The API returned some other error.
105 echo "GitHub API create ERROR: $response"
106 exit 1
107 fi
1b705d2 @convissor Change regex to wildcard in tests to make cygwin happy.
convissor authored
108 elif [[ $response == *'"message"'* ]] ; then
7c94e65 @convissor Expand what the scripts do and break them up into three steps/scripts.
convissor authored
109 # The API returned some other error.
110 echo "GitHub API search ERROR: $response"
111 exit 1
112 fi
113
114
0e29362 @convissor Add web hook to kick off jenkins build.
convissor authored
115 # Create hooks.
14fd0d0 @convissor Call api to create hook that emails pear-cvs list.
convissor authored
116
117 post="{\"name\":\"email\", \"config\":{\"address\":\"pear-cvs@lists.php.net\", \"send_from_author\":true}}"
5c9857a @CloCkWeRX Add support for proxy, when curl doesn't listen to http_proxy, and an…
CloCkWeRX authored
118 response=`curl $curl_args -s -S -u "$user:$pass" -d "$post" $api/repos/pear/$package/hooks`
14fd0d0 @convissor Call api to create hook that emails pear-cvs list.
convissor authored
119 if [ $? -ne 0 ] ; then
65f950e @convissor Clarify error message for email hook choking.
convissor authored
120 echo "ERROR: curl had problem calling GitHub email hooks API."
14fd0d0 @convissor Call api to create hook that emails pear-cvs list.
convissor authored
121 exit 1
1b705d2 @convissor Change regex to wildcard in tests to make cygwin happy.
convissor authored
122 elif [[ $response == *'"errors"'* ]] ; then
14fd0d0 @convissor Call api to create hook that emails pear-cvs list.
convissor authored
123 # The API returned some other error.
124 echo "GitHub API hooks ERROR: $response"
125 exit 1
126 fi
127
0e29362 @convissor Add web hook to kick off jenkins build.
convissor authored
128 post="{\"name\":\"web\", \"config\":{\"url\":\"http://test.pear.php.net:8080/github-webhook/\"}}"
5c9857a @CloCkWeRX Add support for proxy, when curl doesn't listen to http_proxy, and an…
CloCkWeRX authored
129 response=`curl $curl_args -s -S -u "$user:$pass" -d "$post" $api/repos/pear/$package/hooks`
0e29362 @convissor Add web hook to kick off jenkins build.
convissor authored
130 if [ $? -ne 0 ] ; then
131 echo "ERROR: curl had problem calling GitHub web hooks API."
132 exit 1
1b705d2 @convissor Change regex to wildcard in tests to make cygwin happy.
convissor authored
133 elif [[ $response == *'"errors"'* ]] ; then
0e29362 @convissor Add web hook to kick off jenkins build.
convissor authored
134 # The API returned some other error.
135 echo "GitHub API hooks ERROR: $response"
136 exit 1
137 fi
138
14fd0d0 @convissor Call api to create hook that emails pear-cvs list.
convissor authored
139
7c94e65 @convissor Expand what the scripts do and break them up into three steps/scripts.
convissor authored
140 # Everything is ready. Push the package up.
141
142 git push -u origin master
baefa88 @convissor Remove quotes in if expressions.
convissor authored
143 if [ $? -ne 0 ] ; then
7c94e65 @convissor Expand what the scripts do and break them up into three steps/scripts.
convissor authored
144 echo "ERROR: problem pushing $package to GitHub."
145 exit 1
146 fi
147
148
149 # Voila!
150
151 echo ""
d569bb8 @convissor Clearly delineate our result output.
convissor authored
152 echo "------ PEAR MIGRATION RESULT ------"
7c94e65 @convissor Expand what the scripts do and break them up into three steps/scripts.
convissor authored
153 echo "The package has been pushed to GitHub."
154 echo ""
89f5061 @convissor Tell folks to update scm uri in package web interface.
convissor authored
155 echo "There are three things left to do..."
7c94e65 @convissor Expand what the scripts do and break them up into three steps/scripts.
convissor authored
156 echo "1) Check that everything looks right on the GitHub website:"
157 echo " https://github.com/pear/$package"
89f5061 @convissor Tell folks to update scm uri in package web interface.
convissor authored
158 echo ""
159 echo "2) Edit the package's \"Web version control URI\" at"
160 echo " https://pear.php.net/package/$package/"
161 echo " Set it to: https://github.com/pear/$package"
162 echo ""
4325fdb @convissor Tell folks to set jenkins configuration to get data from github.
convissor authored
163 echo "3) Edit the package's settings in Jenkins:"
164 echo " Go to http://test.pear.php.net:8080/job/$package/ ."
165 echo " Log in with your standard PEAR username and password."
166 echo " Click \"Configure\", scroll to the \"Source Code Management\" section."
167 echo " Click the \"Git\" radio button."
168 echo " Put the following in the \"Repository URL\":"
169 echo " \"https://github.com/pear/$package.git\" ."
3474940 @convissor Enhance ending message in step 2.
convissor authored
170 echo ""
4325fdb @convissor Tell folks to set jenkins configuration to get data from github.
convissor authored
171 echo "4) cd .."
172 echo ""
173 echo "5) Run ./3-svn-remove.sh $package"
3474940 @convissor Enhance ending message in step 2.
convissor authored
174 echo ""
Something went wrong with that request. Please try again.