2014-01-06 21:17:31 +00:00
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
|
#
|
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
#
|
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
|
|
|
# implied.
|
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
|
# limitations under the License.
|
|
|
|
|
from __future__ import absolute_import, division, print_function
|
|
|
|
|
|
2014-02-19 22:01:06 +00:00
|
|
|
import getpass
|
2014-02-20 15:48:46 +00:00
|
|
|
import os
|
2014-02-20 00:44:06 +00:00
|
|
|
import time
|
2014-02-19 22:01:06 +00:00
|
|
|
|
2014-01-06 20:04:53 +00:00
|
|
|
import invoke
|
|
|
|
|
|
2014-02-19 22:01:06 +00:00
|
|
|
import requests
|
|
|
|
|
|
|
|
|
|
|
2014-03-15 12:24:45 +00:00
|
|
|
JENKINS_URL = "https://jenkins.cryptography.io/job/cryptography-wheel-builder"
|
2014-02-20 00:44:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def wait_for_build_completed():
|
|
|
|
|
while True:
|
|
|
|
|
response = requests.get(
|
|
|
|
|
"{0}/lastBuild/api/json/".format(JENKINS_URL),
|
|
|
|
|
headers={
|
|
|
|
|
"Accept": "application/json",
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
response.raise_for_status()
|
|
|
|
|
if not response.json()["building"]:
|
2014-02-20 15:48:46 +00:00
|
|
|
assert response.json()["result"] == "SUCCESS"
|
2014-02-20 00:44:06 +00:00
|
|
|
break
|
|
|
|
|
time.sleep(0.1)
|
2014-01-06 20:04:53 +00:00
|
|
|
|
2014-02-19 22:29:37 +00:00
|
|
|
|
2014-02-20 15:48:46 +00:00
|
|
|
def download_artifacts():
|
|
|
|
|
response = requests.get(
|
|
|
|
|
"{0}/lastBuild/api/json/".format(JENKINS_URL),
|
|
|
|
|
headers={
|
|
|
|
|
"Accept": "application/json"
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
response.raise_for_status()
|
|
|
|
|
assert not response.json()["building"]
|
|
|
|
|
assert response.json()["result"] == "SUCCESS"
|
2014-02-20 17:07:53 +00:00
|
|
|
|
|
|
|
|
paths = []
|
|
|
|
|
|
2014-02-20 15:48:46 +00:00
|
|
|
for run in response.json()["runs"]:
|
|
|
|
|
response = requests.get(
|
|
|
|
|
run["url"] + "api/json/",
|
|
|
|
|
headers={
|
|
|
|
|
"Accept": "application/json",
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
response.raise_for_status()
|
|
|
|
|
for artifact in response.json()["artifacts"]:
|
|
|
|
|
response = requests.get(
|
2014-05-04 01:48:03 +00:00
|
|
|
"{0}artifact/{1}".format(run["url"], artifact["relativePath"])
|
2014-02-20 15:48:46 +00:00
|
|
|
)
|
|
|
|
|
out_path = os.path.join(
|
|
|
|
|
os.path.dirname(__file__),
|
|
|
|
|
"dist",
|
|
|
|
|
artifact["fileName"],
|
|
|
|
|
)
|
|
|
|
|
with open(out_path, "wb") as f:
|
|
|
|
|
f.write(response.content)
|
2014-02-20 17:07:53 +00:00
|
|
|
paths.append(out_path)
|
|
|
|
|
return paths
|
2014-02-20 15:48:46 +00:00
|
|
|
|
|
|
|
|
|
2014-01-06 20:04:53 +00:00
|
|
|
@invoke.task
|
|
|
|
|
def release(version):
|
|
|
|
|
"""
|
|
|
|
|
``version`` should be a string like '0.4' or '1.0'.
|
|
|
|
|
"""
|
2014-01-07 19:12:47 +00:00
|
|
|
invoke.run("git tag -s {0}".format(version))
|
2014-01-06 23:28:59 +00:00
|
|
|
invoke.run("git push --tags")
|
2014-01-06 20:04:53 +00:00
|
|
|
|
2014-01-07 19:06:51 +00:00
|
|
|
invoke.run("python setup.py sdist")
|
2014-03-24 23:05:53 +00:00
|
|
|
invoke.run("cd vectors/ && python setup.py sdist bdist_wheel")
|
2014-03-14 20:03:12 +00:00
|
|
|
|
|
|
|
|
invoke.run(
|
|
|
|
|
"twine upload -s dist/cryptography-{0}* "
|
2014-03-24 23:05:53 +00:00
|
|
|
"vectors/dist/cryptography_vectors-{0}*".format(version)
|
2014-03-14 20:03:12 +00:00
|
|
|
)
|
2014-02-19 22:01:06 +00:00
|
|
|
|
2014-06-20 20:32:02 +00:00
|
|
|
username = getpass.getpass("Input the GitHub/Jenkins username: ")
|
2014-02-21 00:10:53 +00:00
|
|
|
token = getpass.getpass("Input the Jenkins token: ")
|
2014-02-19 22:29:37 +00:00
|
|
|
response = requests.post(
|
2014-02-20 00:44:06 +00:00
|
|
|
"{0}/build".format(JENKINS_URL),
|
2014-06-20 20:32:02 +00:00
|
|
|
auth=requests.auth.HTTPBasicAuth(
|
|
|
|
|
username, token
|
|
|
|
|
),
|
2014-02-19 22:01:06 +00:00
|
|
|
params={
|
|
|
|
|
"cause": "Building wheels for {0}".format(version)
|
|
|
|
|
}
|
|
|
|
|
)
|
2014-02-19 22:29:37 +00:00
|
|
|
response.raise_for_status()
|
2014-02-20 00:44:06 +00:00
|
|
|
wait_for_build_completed()
|
2014-02-20 17:07:53 +00:00
|
|
|
paths = download_artifacts()
|
|
|
|
|
invoke.run("twine upload {0}".format(" ".join(paths)))
|