Skip to content

Commit 0ccf28b

Browse files
committed
Added build for Android Play store bundle.
1 parent 3b3aa99 commit 0ccf28b

File tree

12 files changed

+1161
-325
lines changed

12 files changed

+1161
-325
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ debug/
1414
release/
1515
testresults/
1616
.eslintcache
17+
cordova/bundle.keystore
1718

1819
# OSX
1920
.DS_store

azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ stages:
8686
displayName: 'Install Node.js 10.16.3'
8787
- script: yarn install
8888
displayName: 'Run yarn install'
89-
- script: yarn gulp release --android
89+
- script: yarn gulp debug-release --android
9090
displayName: 'Run yarn release for android'
9191
- task: PublishPipelineArtifact@1
9292
displayName: 'Publish Android release'

cordova/build.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

cordova/build_template.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"android": {
3+
"debug": {
4+
"keystore": "debug.keystore",
5+
"storePassword": "betaflight_debug",
6+
"alias": "betaflight_debug",
7+
"password": "password",
8+
"packageType": "apk"
9+
},
10+
"release": {
11+
"keystore": "bundle.keystore",
12+
"storePassword": "[INJECTED_BY_GULPFILE]",
13+
"alias": "betaflight",
14+
"password": "password",
15+
"packageType": "bundle"
16+
}
17+
}
18+
}

cordova/config_template.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
<preference name="SplashMaintainAspectRatio" value="true"/>
3838
<preference name="SplashShowOnlyFirstTime" value="true"/>
3939
<preference name="android-minSdkVersion" value="19"/>
40+
<preference name="android-targetSdkVersion" value="30" />
4041
<config-file parent="/manifest/application/activity" target="AndroidManifest.xml">
4142
<intent-filter>
4243
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"/>

cordova/debug.keystore

2.4 KB
Binary file not shown.

cordova/release.keystore

-2.19 KB
Binary file not shown.

gulpfile.js

Lines changed: 70 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -293,21 +293,48 @@ function processPackage(done, gitRevision, isReleaseBuild) {
293293
metadata.packageId = pkg.name;
294294
}
295295

296-
const packageJson = new stream.Readable;
297-
packageJson.push(JSON.stringify(pkg, undefined, 2));
298-
packageJson.push(null);
299-
300-
Object.keys(pkg)
301-
.filter(key => metadataKeys.includes(key))
302-
.forEach((key) => {
303-
metadata[key] = pkg[key];
304-
});
296+
function version_prompt() {
297+
return gulp.src('.')
298+
.pipe(prompt.prompt([{
299+
type: 'input',
300+
name: 'version',
301+
message: `Package version (default: ${pkg.version}):`,
302+
}, {
303+
type: 'input',
304+
name: 'storeVersion',
305+
message: 'Google Play store version (<x.y.z>, default: package version):',
306+
}], function(res) {
307+
if (res.version) {
308+
pkg.version = res.version;
309+
}
310+
if (res.storeVersion) {
311+
metadata.storeVersion = res.storeVersion;
312+
}
313+
}));
314+
};
305315

306-
packageJson
307-
.pipe(source('package.json'))
308-
.pipe(gulp.dest(DIST_DIR));
316+
function write_package_file() {
317+
Object.keys(pkg)
318+
.filter(key => metadataKeys.includes(key))
319+
.forEach((key) => {
320+
metadata[key] = pkg[key];
321+
});
309322

310-
done();
323+
const packageJson = new stream.Readable;
324+
packageJson.push(JSON.stringify(pkg, undefined, 2));
325+
packageJson.push(null);
326+
327+
return packageJson
328+
.pipe(source('package.json'))
329+
.pipe(gulp.dest(DIST_DIR));
330+
};
331+
332+
const platforms = getPlatforms();
333+
if (platforms.indexOf('android') !== -1 && isReleaseBuild) {
334+
gulp.series(version_prompt, write_package_file)(done);
335+
} else {
336+
gulp.series(write_package_file)(done);
337+
}
311338
}
312339

313340
function dist_src() {
@@ -466,7 +493,7 @@ function debug(done) {
466493
buildNWAppsWrapper(platforms, 'sdk', DEBUG_DIR, done);
467494
}
468495

469-
function injectARMCache(flavor, callback) {
496+
function injectARMCache(flavor, done) {
470497
const flavorPostfix = `-${flavor}`;
471498
const flavorDownloadPostfix = flavor !== 'normal' ? `-${flavor}` : '';
472499
clean_cache().then(function() {
@@ -529,7 +556,7 @@ function injectARMCache(flavor, callback) {
529556
clean_debug();
530557
process.exit(1);
531558
}
532-
callback();
559+
done();
533560
}
534561
);
535562
}
@@ -593,10 +620,10 @@ function buildNWApps(platforms, flavor, dir, done) {
593620

594621
function getGitRevision(done, callback, isReleaseBuild) {
595622
let gitRevision = 'norevision';
596-
git.diff([ '--shortstat' ], function (err, diff) {
597-
if (!err && !diff) {
598-
git.log([ '-1', '--pretty=format:%h' ], function (err, rev) {
599-
if (!err) {
623+
git.diff([ '--shortstat' ], function (err1, diff) {
624+
if (!err1 && !diff) {
625+
git.log([ '-1', '--pretty=format:%h' ], function (err2, rev) {
626+
if (!err2) {
600627
gitRevision = rev.latest.hash;
601628
}
602629

@@ -881,7 +908,7 @@ function listReleaseTasks(isReleaseBuild, appDirectory) {
881908
}
882909

883910
// Cordova
884-
function cordova_dist(isReleaseBuild) {
911+
function cordova_dist() {
885912
const distTasks = [];
886913
const platforms = getPlatforms();
887914
if (platforms.indexOf('android') !== -1) {
@@ -995,7 +1022,7 @@ function cordova_manifestjson() {
9951022
}
9961023

9971024
function cordova_configxml() {
998-
let androidName = metadata.packageId.replace(NAME_REGEX, '_');
1025+
const androidName = metadata.packageId.replace(NAME_REGEX, '_');
9991026

10001027
return gulp.src([`${CORDOVA_DIST_DIR}config.xml`])
10011028
.pipe(xmlTransformer([
@@ -1005,37 +1032,18 @@ function cordova_configxml() {
10051032
], 'http://www.w3.org/ns/widgets'))
10061033
.pipe(xmlTransformer([
10071034
{ path: '.', attr: { 'id': `com.betaflight.${androidName}` } },
1008-
{ path: '.', attr: { 'version': metadata.version } },
1035+
{ path: '.', attr: { 'version': metadata.storeVersion ? metadata.storeVersion : metadata.version } },
10091036
]))
10101037
.pipe(gulp.dest(CORDOVA_DIST_DIR));
10111038
}
10121039

1013-
function cordova_debug_configxml() {
1014-
return cordova_configxml_internal();
1015-
}
1016-
1017-
function cordova_configxml(callback) {
1018-
return gulp.series(function version_prompt() {
1019-
return gulp.src('.')
1020-
.pipe(prompt.prompt({
1021-
type: 'input',
1022-
name: 'version',
1023-
message: `Bundle version (default: ${metadata.version}):`,
1024-
}, function(res) {
1025-
if (res.version) {
1026-
metadata.version = res.version;
1027-
}
1028-
}));
1029-
}, cordova_configxml_internal)(callback);
1030-
}
1031-
10321040
function cordova_rename_build_json() {
10331041
return gulp.src(`${CORDOVA_DIR}build_template.json`)
10341042
.pipe(rename('build.json'))
10351043
.pipe(gulp.dest(CORDOVA_DIST_DIR));
10361044
}
10371045

1038-
function cordova_browserify(callback) {
1046+
function cordova_browserify(done) {
10391047
const readFile = function(file) {
10401048
return new Promise(function(resolve) {
10411049
if (!file.includes("node_modules")) {
@@ -1053,7 +1061,7 @@ function cordova_browserify(callback) {
10531061
glob(`${CORDOVA_DIST_DIR}www/**/*.js`, {}, function (err, files) {
10541062
const readLoop = function() {
10551063
if (files.length === 0) {
1056-
callback();
1064+
done();
10571065
} else {
10581066
const file = files.pop();
10591067
readFile(file).then(function() {
@@ -1092,7 +1100,7 @@ function cordova_debug() {
10921100
cordova.run();
10931101
}
10941102

1095-
function cordova_debug_build(cb) {
1103+
function cordova_debug_build(done) {
10961104
cordova.build({
10971105
'platforms': ['android'],
10981106
'options': {
@@ -1101,13 +1109,14 @@ function cordova_debug_build(cb) {
11011109
},
11021110
}).then(function() {
11031111
process.chdir('../');
1104-
cb();
1105-
});
11061112

1107-
console.log(`APK will be generated at ${CORDOVA_DIST_DIR}platforms/android/app/build/outputs/apk/release/app-release.apk`);
1113+
console.log(`APK has been generated at ${CORDOVA_DIST_DIR}platforms/android/app/build/outputs/apk/release/app-release.apk`);
1114+
1115+
done();
1116+
});
11081117
}
11091118

1110-
function cordova_build(callback) {
1119+
function cordova_build(done) {
11111120
let storePassword = '';
11121121
return gulp.series(function password_prompt() {
11131122
return gulp.src('.')
@@ -1124,11 +1133,11 @@ function cordova_build(callback) {
11241133
'android': {
11251134
'release' : {
11261135
'storePassword': storePassword,
1127-
}
1128-
}
1136+
},
1137+
},
11291138
}))
11301139
.pipe(gulp.dest('./'));
1131-
}, function build(cb) {
1140+
}, function build(done) {
11321141
return cordova.build({
11331142
'platforms': ['android'],
11341143
'options': {
@@ -1139,24 +1148,28 @@ function cordova_build(callback) {
11391148
// Delete the file containing the store password
11401149
del(['build.json'], { force: true });
11411150
process.chdir('../');
1142-
cb();
1143-
});
1144-
})(callback);
11451151

1146-
console.log('AAB will be generated at dist_cordova/platforms/android/app/build/outputs/bundle/release/app.aab');
1152+
console.log('AAB has been generated at dist_cordova/platforms/android/app/build/outputs/bundle/release/app.aab');
1153+
done();
1154+
});
1155+
})(done);
11471156
}
11481157

11491158
async function cordova_debug_release() {
1150-
const filename = await getReleaseFilename('android', 'apk');
1159+
const filename = getReleaseFilename('android', 'apk');
1160+
11511161
console.log(`Release APK : release/${filename}`);
1162+
11521163
return gulp.src(`${CORDOVA_DIST_DIR}platforms/android/app/build/outputs/apk/debug/app-debug.apk`)
11531164
.pipe(rename(filename))
11541165
.pipe(gulp.dest(RELEASE_DIR));
11551166
}
11561167

11571168
async function cordova_release() {
1158-
const filename = await getReleaseFilename('android', 'aab');
1169+
const filename = getReleaseFilename('android', 'aab');
1170+
11591171
console.log(`Release AAB : release/${filename}`);
1172+
11601173
return gulp.src(`${CORDOVA_DIST_DIR}platforms/android/app/build/outputs/bundle/release/app.aab`)
11611174
.pipe(rename(filename))
11621175
.pipe(gulp.dest(RELEASE_DIR));

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
"browserify": "^17.0.0",
8484
"chai": "^4.2.0",
8585
"command-exists": "^1.2.8",
86-
"cordova-lib": "^9.0.1",
86+
"cordova-lib": "^10.0.0",
8787
"del": "^5.0.0",
8888
"eslint": "^7.16.0",
8989
"eslint-plugin-vue": "^7.3.0",
@@ -94,6 +94,7 @@
9494
"gulp-concat": "~2.6.1",
9595
"gulp-debian": "~0.1.8",
9696
"gulp-json-editor": "^2.5.4",
97+
"gulp-prompt": "^1.2.0",
9798
"gulp-rename": "^2.0.0",
9899
"gulp-replace": "^1.0.0",
99100
"gulp-xml-transformer": "^3.0.0",

src/js/backup_restore.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
function configuration_backup(callback) {
66
let activeProfile = null;
77

8-
let version = CONFIGURATOR.getConfiguratorVersion();
8+
let version = CONFIGURATOR.version;
99

1010
if (version.indexOf(".") === -1) {
1111
version = version + ".0.0";

0 commit comments

Comments
 (0)