forked from antlr/antlr4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.py
executable file
·159 lines (127 loc) · 5 KB
/
deploy.py
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#!/usr/bin/env python
import os
"""
This script uses my experimental build tool http://www.bildtool.org
This script deploys artifacts created by bild.py.
Windows build using this script is not yet supported.
cd /usr/local/antlr/antlr4
./deploy.py maven_snapshot
or
./deploy.py maven
or
./deploy.py pypi
or
./deploy.py # does "all"
This script must be run from the main antlr4 directory.
"""
# bootstrap by downloading bilder.py if not found
import urllib
import os
if not os.path.exists("bilder.py"):
print "bootstrapping; downloading bilder.py"
urllib.urlretrieve(
"https://raw.githubusercontent.com/parrt/bild/master/src/python/bilder.py",
"bilder.py")
# assumes bilder.py is in current directory
from bilder import *
VERSION = "4.5"
PYTHON2_TARGET = "../antlr4-python2"
PYTHON3_TARGET = "../antlr4-python3"
CSHARP_TARGET = "../antlr4-csharp"
JAVASCRIPT_TARGET = "../antlr4-javascript"
def mvn_snapshot(): # assumes that you have ~/.m2/settings.xml set up
binjar = uniformpath("dist/antlr4-%s-complete.jar" % VERSION)
docjar = uniformpath("dist/antlr4-%s-complete-javadoc.jar" % VERSION)
srcjar = uniformpath("dist/antlr4-%s-complete-sources.jar" % VERSION)
mvn(command="deploy:deploy-file",
binjar=binjar,
srcjar=srcjar,
docjar=docjar,
repositoryid="ossrh",
artifactid="antlr4",
pomfile="tool/pom.xml",
url="https://oss.sonatype.org/content/repositories/snapshots")
binjar = uniformpath("dist/antlr4-%s.jar" % VERSION)
docjar = uniformpath("dist/antlr4-%s-javadoc.jar" % VERSION)
srcjar = uniformpath("dist/antlr4-%s-sources.jar" % VERSION)
mvn(command="deploy:deploy-file",
binjar=binjar,
srcjar=srcjar,
docjar=docjar,
repositoryid="ossrh", artifactid="antlr4-runtime",
pomfile="runtime/Java/pom.xml",
url="https://oss.sonatype.org/content/repositories/snapshots")
# deploy to maven central
def mvn_deploy(): # assumes that you have ~/.m2/settings.xml set up
"""
mvn gpg:sign-and-deploy-file \
-Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ \
-DrepositoryId=ossrh \
-Dpackaging=jar \
-DpomFile=/Users/parrt/antlr/code/antlr4/tool/pom.xml \
-Dfile=/Users/parrt/antlr/code/antlr4/dist/antlr4-4.5-complete.jar \
-Dsources=/Users/parrt/antlr/code/antlr4/dist/antlr4-4.5-complete-sources.jar \
-Djavadoc=/Users/parrt/antlr/code/antlr4/dist/antlr4-4.5-complete-javadoc.jar
mvn gpg:sign-and-deploy-file \
-Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ \
-DrepositoryId=ossrh \
-Dpackaging=jar \
-DpomFile=/Users/parrt/antlr/code/antlr4/runtime/Java/pom.xml \
-Dfile=/Users/parrt/antlr/code/antlr4/dist/antlr4-4.5.jar \
-Dsources=/Users/parrt/antlr/code/antlr4/dist/antlr4-4.5-sources.jar \
-Djavadoc=/Users/parrt/antlr/code/antlr4/dist/antlr4-4.5-javadoc.jar
"""
# deploy the tool and Java runtime, it becomes antlr4 artifact at maven
binjar = uniformpath("dist/antlr4-%s-complete.jar" % VERSION)
docjar = uniformpath("dist/antlr4-%s-complete-javadoc.jar" % VERSION)
srcjar = uniformpath("dist/antlr4-%s-complete-sources.jar" % VERSION)
mvn(command="gpg:sign-and-deploy-file",
binjar=binjar,
srcjar=srcjar,
docjar=docjar, repositoryid="ossrh",
pomfile="tool/pom.xml",
url="https://oss.sonatype.org/service/local/staging/deploy/maven2/")
# deploy the runtime, it becomes antlr4-runtime artifact at maven
binjar = uniformpath("dist/antlr4-%s.jar" % VERSION)
docjar = uniformpath("dist/antlr4-%s-javadoc.jar" % VERSION)
srcjar = uniformpath("dist/antlr4-%s-sources.jar" % VERSION)
mvn("gpg:sign-and-deploy-file",
binjar=binjar,
srcjar=srcjar,
docjar=docjar, repositoryid="ossrh",
pomfile="runtime/Java/pom.xml",
url="https://oss.sonatype.org/service/local/staging/deploy/maven2/")
def pypi(): # assumes that you have ~/.pypirc set up
cmd = ["python", "setup.py", "register", "-r", "pypi"]
savedir= os.getcwd()
try:
os.chdir(uniformpath(PYTHON2_TARGET))
exec_and_log(cmd)
os.chdir(uniformpath(PYTHON3_TARGET))
exec_and_log(cmd)
finally:
os.chdir(savedir)
# Upload the source distribution and the Windows installer to PyPI
cmd = ["python", "setup.py", "sdist", "bdist_wininst", "upload", "-r", "pypi"]
savedir= os.getcwd()
try:
os.chdir(uniformpath(PYTHON2_TARGET))
exec_and_log(cmd)
os.chdir(uniformpath(PYTHON3_TARGET))
exec_and_log(cmd)
finally:
os.chdir(savedir)
def nuget(): # TODO
pass
def website():
"""
Push all jars, source, target artifacts etc.
"""
# There is no JavaScript project i.e; nothing to "build" it's just a bunch of files that I zip.
pass
def all(): # Note: building artifacts is in a separate file bild.py
mvn()
pypi()
nuget()
website()
processargs(globals()) # E.g., "python bild.py all"