Skip to content

Commit 5e11335

Browse files
author
Cameron Mace
authored
update release script for circleci (#541)
1 parent 04e9367 commit 5e11335

1 file changed

Lines changed: 23 additions & 25 deletions

File tree

scripts/release.py

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'''
2-
Utility to schedule MAS builds in Bitrise.
2+
Utility to schedule MAS builds on CircleCI.
33
44
Examples:
55
@@ -33,7 +33,7 @@
3333
3434
TODO:
3535
36-
- Add a flag to wait until the release has been built (Bitrise) and published (Maven).
36+
- Add a flag to wait until the release has been built (CircleCI) and published (Maven).
3737
3838
'''
3939

@@ -49,8 +49,8 @@
4949
# Get the version from GRADLE_PROPERTIES_PATH below
5050
CURRENT_VERSION_TAG = 'current'
5151

52-
# You can find the API token in https://www.bitrise.io/app/a7eea7d04be1e2e5#/code -> API token
53-
BITRISE_API_TOKEN_ENV_VAR = 'BITRISE_API_TOKEN_MAS'
52+
# You can add your API token onhttps://circleci.com/account/api
53+
CIRCLECI_API_TOKEN_ENV_VAR = 'CIRCLECI_API_TOKEN'
5454

5555
# In the future we might want to consider alpha, or rc.
5656
ALLOWED_PRE_RELEASE = ['beta']
@@ -60,8 +60,8 @@
6060
GRADLE_PROPERTIES_PATH = '%s/gradle.properties' % MAPBOX_GL_ANDROID_SDK_PATH
6161
GRADLE_TOKEN = 'VERSION_NAME='
6262

63-
# Bitrise
64-
URL_BITRISE = 'https://www.bitrise.io/app/a7eea7d04be1e2e5/build/start.json'
63+
# Triggers a new build, returns a summary of the build
64+
URL_CIRCLECI = 'https://circleci.com/api/v1.1/project/github/mapbox/mapbox-gl-native/tree/' # + :branch
6565

6666
# We support three parameters: stage, branch, and version
6767
@click.command()
@@ -127,23 +127,23 @@ def publish_snapshot(branch, version):
127127
if dirty_gradle:
128128
git_add(path=GRADLE_PROPERTIES_PATH)
129129
git_commit_and_push(branch=branch, version=version)
130-
do_bitrise_request(build_params={'branch': branch, 'workflow_id': 'scheduled'})
130+
do_circleci_request(branch=branch)
131131

132132
def publish_beta(branch, version):
133133
click.echo('Publishing beta from branch: %s (version: %s).' % (branch, version))
134134
dirty_gradle = update_current_version(file_path=GRADLE_PROPERTIES_PATH, file_var=GRADLE_TOKEN, version=version)
135135
if dirty_gradle:
136136
git_add(path=GRADLE_PROPERTIES_PATH)
137137
git_commit_and_push(branch=branch, version=version)
138-
do_bitrise_request(build_params={'branch': branch, 'workflow_id': 'scheduled'})
138+
do_circleci_request(branch=branch)
139139

140140
def publish_final(branch, version):
141141
click.echo('Publishing final release from branch: %s (version: %s).' % (branch, version))
142142
dirty_gradle = update_current_version(file_path=GRADLE_PROPERTIES_PATH, file_var=GRADLE_TOKEN, version=version)
143143
if dirty_gradle:
144144
git_add(path=GRADLE_PROPERTIES_PATH)
145145
git_commit_and_push(branch=branch, version=version)
146-
do_bitrise_request(build_params={'branch': branch, 'workflow_id': 'scheduled'})
146+
do_circleci_request(branch=branch)
147147

148148
#
149149
# Utils
@@ -160,26 +160,24 @@ def execute_call(command):
160160
abort_with_message('Command failed: %s' % command)
161161

162162
#
163-
# Bitrise
163+
# CircleCI
164164
#
165165

166-
def get_bitrise_api_token():
167-
bitrise_api_token = os.environ.get(BITRISE_API_TOKEN_ENV_VAR)
168-
if not bitrise_api_token:
169-
abort_with_message('You need to set the BITRISE_API_TOKEN_MAS environment variable.')
170-
click.echo('Found Bitrise API token.')
171-
return bitrise_api_token
172-
173-
def do_bitrise_request(build_params):
174-
data = {
175-
'hook_info': {'type': 'bitrise', 'api_token': get_bitrise_api_token()},
176-
'build_params' : build_params}
177-
click.echo('Bitrise request data: %s' % json.dumps(data))
166+
def get_circleci_api_token():
167+
circleci_api_token = os.environ.get(CIRCLECI_API_TOKEN_ENV_VAR)
168+
if not circleci_api_token:
169+
abort_with_message('You need to set the CIRCLECI_API_TOKEN environment variable.')
170+
click.echo('Found CircleCI API token.')
171+
return circleci_api_token
172+
173+
def do_circleci_request(branch):
174+
url = URL_CIRCLECI + branch
175+
params = {'circle-token': get_circleci_api_token()}
176+
click.echo('CircleCI request to %s (params: %s)' % (url, json.dumps(params)))
178177
click.confirm('\nDo you want to start a build?', abort=True)
179178

180-
r = requests.post(URL_BITRISE, data=json.dumps(data))
181-
click.echo('- Bitrise response code: %s' % r.status_code)
182-
click.echo('- Bitrise response content: %s' % r.text)
179+
r = requests.post(url, params=params)
180+
click.echo('- CircleCI response code: %s' % r.status_code)
183181

184182
#
185183
# Git

0 commit comments

Comments
 (0)