Skip to content

Commit c6daac8

Browse files
committed
add release Ant target
1 parent 4313018 commit c6daac8

File tree

3 files changed

+60
-15
lines changed

3 files changed

+60
-15
lines changed

build.xml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
9595
<property name="distname" value="opengrok"/>
9696
<property name="src.dir" location="src"/>
9797
<property name="src.generatedsrc.dir" location="generatedsrc"/>
98+
<property name="tardest" value="${distname}-${version}.tar.gz"/>
9899

99100
<property name="findbugs.home" value="${user.home}/.ant/lib/findbugs"/>
100101
<property name="checkstyle.home" value="${user.home}/.ant/lib/checkstyle"/>
@@ -507,7 +508,7 @@ Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
507508
</target>
508509

509510
<target name="dist" depends="jar">
510-
<tar destfile="${dist.dir}/${distname}-${version}.tar.gz"
511+
<tar destfile="${dist.dir}/${tardest}"
511512
compression="gzip">
512513
<tarfileset dir="." prefix="${distname}-${version}/doc">
513514
<include name="README.txt"/>
@@ -950,6 +951,7 @@ Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
950951
<property name="codebase" value="org/opensolaris/opengrok"/>
951952
<property name="codebase.dot" value="org.opensolaris.opengrok"/>
952953
<property name="web.src.dir" location="web" />
954+
<property name="tools.dir" location="tools" />
953955

954956
<patternset id="libs">
955957
<include name="*.jar" />
@@ -1044,5 +1046,18 @@ Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
10441046
</javac>
10451047
</target>
10461048

1049+
<target name="release" depends="dist,package">
1050+
<exec os="SunOS" executable="${tools.dir}/dorelease.py" failonerror="true">
1051+
<arg value="-d"/>
1052+
<arg value="-D new"/>
1053+
<arg value="-t ${version}"/>
1054+
<!-- The directory of the files should really be ${dist.dir} however it does not work. -->
1055+
<arg file="dist/${tardest}"/>
1056+
<!-- These 2 files should really be conditional to avoid the whole target to be SunOS dependent. -->
1057+
<arg file="dist/OSOLopengrok-${version}.pkg"/>
1058+
<arg file="dist/${distname}-${version}.p5p"/>
1059+
</exec>
1060+
</target>
1061+
10471062
<target name="all" depends="clean,jar,compile.jsp,test,javadoc,pmd,findbugs-xml,checkstyle" />
10481063
</project>

doc/release.txt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ jars/dirs for tests
1919

2020
ant clean
2121
ant # defaults to jar currently
22-
ant package
2322

2423
2) check all tests, tests code coverage:
2524
junit, pmd, findbugs, checkstyle, emma, jdepend
@@ -34,7 +33,7 @@ The release is OK, once above is fullfilled to our satisfaction.
3433

3534
3) produce proper distributions
3635

37-
Check them before upload, always try to build on Solaris, since gnu tar might
36+
Check them before upload, always try to build on Solaris, since GNU tar might
3837
create a non-standard compliant .tgz version and tag from step 0) will be used
3938
to produce the archive
4039

@@ -68,9 +67,14 @@ number (0.12))
6867

6968
4) Create the release and upload the files via GitHub API:
7069

71-
./tools/dorelease.py -d -u <github_login> \
72-
-D "some release description" \
73-
-t <tag> dist/*.p5p dist/*.pkg dist/*.tar.gz
70+
First, make sure these environment variables are set:
7471

75-
Note: for pre-releases use the -P option
72+
GITHUB_USER (your Github user name)
73+
GITHUB_PASSWORD (your Github password)
74+
https_proxy (set to host:port of proxy if behind HTTP proxy)
75+
OPENGROK_PRERELEASE (set to non-empty if creating release candidate)
76+
77+
Next:
78+
79+
ant release
7680

tools/dorelease.py

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,16 @@ def get_args():
107107
description='Create release using Github API.')
108108
parser.add_argument("-d", "--debug", help="turn on debugging",
109109
action="store_true")
110+
parser.add_argument("-n", "--dryrun", help="perform dry run",
111+
action="store_true")
110112
parser.add_argument("-u", "--user", nargs=1, metavar='user',
111-
required=True,
112-
help="GitHub user. Specify password with GITHUB_PASSWORD env var.")
113+
help="GitHub user. Specify user with GITHUB_USER and password with GITHUB_PASSWORD env var.")
113114
parser.add_argument("-D", "--description", nargs=1,
114115
metavar='description', required=True,
115116
help="Description text for the release")
116117
parser.add_argument("-P", "--prerelease",
117118
default = False, action="store_true",
118-
help="Is this a pre-release ?")
119+
help="Is this a pre-release ? (also can use OPENGROK_PRERELEASE env var)")
119120
parser.add_argument("-t", "--tag", nargs=1, metavar='tag',
120121
required=True, help="New release tag")
121122
parser.add_argument("-p", "--proxy", nargs=1,
@@ -185,6 +186,16 @@ def upload_file(filepath, upload_url, headers, timeout, proxy=None):
185186
def main():
186187
arguments = get_args()
187188

189+
user = None
190+
if not arguments.user:
191+
try:
192+
user = os.environ["GITHUB_USER"]
193+
except:
194+
print "Need -u or specify user with GITHUB_USER env var"
195+
sys.exit(1)
196+
else:
197+
user = arguments.user[0]
198+
188199
if arguments.debug:
189200
logging.basicConfig(
190201
level=logging.DEBUG,
@@ -195,10 +206,9 @@ def main():
195206

196207
# There is exactly 1 item in the list.
197208
# TODO: there should be better way how to achieve this.
198-
user = arguments.user[0]
199209
description = arguments.description[0]
200-
tag = arguments.tag[0]
201-
logger.debug("using tag {}".format(tag))
210+
tag = arguments.tag[0].strip()
211+
logger.debug("using tag '{}'".format(tag))
202212

203213
proxy = None
204214
if arguments.proxy:
@@ -214,6 +224,7 @@ def main():
214224
# First check that the files indeed exist and are readable.
215225
# TODO: can probably do it from parser using action
216226
for file in arguments.files:
227+
logger.debug("checking file {}".format(file))
217228
if not os.path.isfile(file) or not os.access(file, os.R_OK):
218229
print "file '" + file + "' does not exist or is not readable"
219230
sys.exit(1)
@@ -234,16 +245,31 @@ def main():
234245
headers = {}
235246
headers['Authorization'] = _get_auth(user, password)
236247

248+
prerelease = False
249+
if arguments.prerelease:
250+
prerelease = True
251+
else:
252+
try:
253+
if os.environ["OPENGROK_PRERELEASE"]:
254+
prerelease = True
255+
except:
256+
prerelease = False
257+
237258
# Create new release and get the upload URL.
238-
rel_dict = get_release_dict(tag, description, arguments.prerelease)
259+
rel_dict = get_release_dict(tag, description, prerelease)
239260
payload = json.dumps(rel_dict)
240261
if (arguments.debug):
241262
pprint(rel_dict)
242263
pprint(payload)
243264
upload_url = None
265+
266+
if arguments.dryrun:
267+
print "Dry run in effect, exiting"
268+
sys.exit(0)
269+
244270
try:
245271
_url = "https://api.github.com"
246-
url = '%s%s' % (_url, "/repos/vladak/foo/releases")
272+
url = '%s%s' % (_url, "/repos/OpenGrok/OpenGrok/releases")
247273
release_json = post_request(url,
248274
arguments.timeout, payload, headers, proxy)
249275
upload_url = release_json["upload_url"]

0 commit comments

Comments
 (0)