Skip to content

Commit

Permalink
use text from changelog file for playstore release notes
Browse files Browse the repository at this point in the history
  • Loading branch information
tiltec committed Sep 27, 2018
1 parent 605db72 commit a9fc960
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 21 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Expand Up @@ -7,3 +7,7 @@ indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.py]
indent_size = 4
max_line_length = 119
10 changes: 10 additions & 0 deletions cordova/playstoreHelper/.style.yapf
@@ -0,0 +1,10 @@
[style]
based_on_style = pep8
split_before_logical_operator = true
dedent_closing_brackets = true
split_before_first_argument = true
coalesce_brackets = true
column_limit = 119
each_dict_entry_on_separate_line = true
split_arguments_when_comma_terminated = true
split_before_bitwise_operator = false
39 changes: 20 additions & 19 deletions cordova/playstoreHelper/publish_to_beta.py
Expand Up @@ -4,6 +4,7 @@
import socket
from apiclient.discovery import build
from oauth2client.service_account import ServiceAccountCredentials
import subprocess

TRACK = 'beta'
USER_FRACTION = 1
Expand All @@ -13,25 +14,30 @@


def main(argv):
print('Retrieving release notes from CHANGELOG.md...')
releaseText = subprocess.run('../../scripts/get_newest_release.js', stdout=subprocess.PIPE).stdout
print()
print(releaseText)
print()

credentials = ServiceAccountCredentials.from_json_keyfile_name(
CREDENTIALS_JSON,
scopes=['https://www.googleapis.com/auth/androidpublisher'])
CREDENTIALS_JSON, scopes=['https://www.googleapis.com/auth/androidpublisher']
)

print('Found credentials, trying to connect...')

socket.setdefaulttimeout(900)
service = build('androidpublisher', 'v3', credentials=credentials)

edit_response = service.edits().insert(
body={}, packageName=PACKAGE_NAME).execute()
edit_response = service.edits().insert(body={}, packageName=PACKAGE_NAME).execute()
edit_id = edit_response['id']
print('Inserted edit with ID', edit_id)

print('Uploading APK...')

apk_response = service.edits().apks().upload(
editId=edit_id, packageName=PACKAGE_NAME,
media_body=APK_FILE).execute()
editId=edit_id, packageName=PACKAGE_NAME, media_body=APK_FILE
).execute()

print('Version code %d has been uploaded' % apk_response['versionCode'])

Expand All @@ -42,24 +48,19 @@ def main(argv):
body={
'releases': [{
'releaseNotes': [{
'text':
'New karrot release (published via API)',
'language':
'en-US'
'text': releaseText,
'language': 'en-US'
}],
'versionCodes': [apk_response['versionCode']],
'userFraction':
USER_FRACTION,
'status':
'inProgress',
'userFraction': USER_FRACTION,
'status': 'inProgress',
}]
}).execute()
}
).execute()

print('Track %s is set with releases: %s' %
(track_response['track'], str(track_response['releases'])))
print('Track %s is set with releases: %s' % (track_response['track'], str(track_response['releases'])))

commit_request = service.edits().commit(
editId=edit_id, packageName=PACKAGE_NAME).execute()
commit_request = service.edits().commit(editId=edit_id, packageName=PACKAGE_NAME).execute()

print('Edit "%s" has been committed' % (commit_request['id']))

Expand Down
15 changes: 15 additions & 0 deletions scripts/get_newest_release.js
@@ -0,0 +1,15 @@
#!/usr/bin/env node

/**
* Returns details about newest release from CHANGELOG.md
*/

const { parser } = require('keep-a-changelog')
const fs = require('fs')
const { resolve } = require('path')

const changelogFilePath = resolve(__dirname, '../CHANGELOG.md')

const changelog = parser(fs.readFileSync(changelogFilePath, 'UTF-8'))
const latestRelease = changelog.releases.find(r => r.version)
console.log(latestRelease.toString())
8 changes: 6 additions & 2 deletions scripts/prepare_release.js
Expand Up @@ -12,9 +12,13 @@ const { parser, Release } = require('keep-a-changelog')
const fs = require('fs')
const { execSync } = require('child_process')
const CordovaConfig = require('cordova-config')
const { resolve } = require('path')

const changelogFilePath = './CHANGELOG.md'
const cordovaConfigPaths = ['./cordova/config/dev/config.xml', './cordova/config/prod/config.xml']
const changelogFilePath = resolve(__dirname, '../CHANGELOG.md')
const cordovaConfigPaths = [
resolve(__dirname, '../cordova/config/dev/config.xml'),
resolve(__dirname, '../cordova/config/prod/config.xml'),
]

// Parse changelog file and get latest release
const changelog = parser(fs.readFileSync(changelogFilePath, 'UTF-8'))
Expand Down

0 comments on commit a9fc960

Please sign in to comment.