status-mobile/ci/android.groovy

171 lines
4.5 KiB
Groovy
Raw Normal View History

nix = load 'ci/nix.groovy'
utils = load 'ci/utils.groovy'
def bundle() {
/* we use the method because parameter build type does not take e2e into account */
def btype = utils.getBuildType()
/* Disable Gradle Daemon https://stackoverflow.com/questions/38710327/jenkins-builds-fail-using-the-gradle-daemon */
def gradleOpt = "-PbuildUrl='${currentBuild.absoluteUrl}' --console plain "
/* we don't need x86 for any builds except e2e */
env.ANDROID_ABI_INCLUDE="armeabi-v7a;arm64-v8a"
env.ANDROID_ABI_SPLIT="false"
/* some builds tyes require different architectures */
switch (btype) {
case 'e2e':
env.ANDROID_ABI_INCLUDE="x86" /* e2e builds are used with simulators */
break
case 'release':
env.ANDROID_ABI_SPLIT="true"
gradleOpt += "-PreleaseVersion='${utils.getVersion()}'"
break
}
/* credentials necessary to open the keystore and sign the APK */
withCredentials([
string(
credentialsId: 'android-keystore-pass',
variable: 'STATUS_RELEASE_STORE_PASSWORD'
),
usernamePassword(
credentialsId: 'android-keystore-key-pass',
usernameVariable: 'STATUS_RELEASE_KEY_ALIAS',
passwordVariable: 'STATUS_RELEASE_KEY_PASSWORD'
)
]) {
/* Nix target which produces the final APKs */
nix.build(
attr: 'targets.mobile.android.release',
args: [
'gradle-opts': gradleOpt,
'build-number': utils.readBuildNumber(),
'build-type': btype,
],
safeEnv: [
'STATUS_RELEASE_KEY_ALIAS',
'STATUS_RELEASE_STORE_PASSWORD',
'STATUS_RELEASE_KEY_PASSWORD',
],
keep: [
'ANDROID_ABI_SPLIT',
'ANDROID_ABI_INCLUDE',
'STATUS_RELEASE_STORE_FILE',
],
sbox: [
env.STATUS_RELEASE_STORE_FILE,
],
link: false
)
}
/* necessary for Fastlane */
def apks = renameAPKs()
/* for use with Fastlane */
env.APK_PATHS = apks.join(";")
return apks
}
def extractArchFromAPK(name) {
def pattern = /app-(.+)-[^-]+.apk/
/* extract architecture from filename */
def matches = (name =~ pattern)
if (matches.size() > 0) {
return matches[0][1]
}
if (utils.getBuildType() == 'e2e') {
return 'x86'
}
/* non-release builds make universal APKs */
return 'universal'
}
/**
* We need more informative filenames for all builds.
* For more details on the format see utils.pkgFilename().
**/
def renameAPKs() {
/* find all APK files */
def apkGlob = 'result/*.apk'
def found = findFiles(glob: apkGlob)
if (found.size() == 0) {
throw "APKs not found via glob: ${apkGlob}"
}
def renamed = []
/* rename each for upload & archiving */
for (apk in found) {
def arch = extractArchFromAPK(apk)
def pkg = utils.pkgFilename(env.BUILD_TYPE, 'apk', arch)
def newApk = "result/${pkg}"
renamed += newApk
sh "cp ${apk.path} ${newApk}"
}
return renamed
}
def uploadToPlayStore(type = 'nightly') {
withCredentials([
string(credentialsId: "SUPPLY_JSON_KEY_DATA", variable: 'GOOGLE_PLAY_JSON_KEY'),
]) {
nix.shell(
"fastlane android ${type}",
major nix refactor Changes: - Adds a new `nix-gc` Makefile target for removing old packages - Moves all `nix/*.sh` files to `nix/scripts/*.sh` to make things more tidy - Renames `TARGET_OS` into `TARGET` and makes it effective only with `nix/scripts/shell.sh` - Renames `target-os` Nix argument to just `target` and makes it effective only with `shell.nix` - Drops `IN_CI_ENVIRONMENT` env variable which was useless - Drops use of `target-os` argument outside of `shell.nix` (with few exceptions, but just in naming) - `nix/platform.nix` has been made obsolete and removed - Moves the definition of all major targets to `nix/targets.nix` - Moves the definition of all major shells to `nix/shells.nix` - Makes `default.nix` and `shell.nix` just thin wrappers around `nix/default.nix` - `nix/nixpkgs-bootstrap.nix` has been moved to `nix/pkgs.nix` - All package and tool overrides have been moved to `nix/pkgs.nix` - Explicit passing of contents of `pkgs` has been removed in favor of `callPackage` doing it for us - `nix/bootstrapped-shell.nix` has been moved to `nix/tools/mkShell.nix` - A new `mergeSh` tool has been added to `pkgs` from `nix/tools/mergeSh.nix` - This tool is used to merge shells created using `mkShell` - `mobile/targets/jsbundle.nix` has been moved to `mobile/android/jsbundle/default.nix` - Moves `status-go` version sanitization to `nix/status-go/utils.nix` - Renames version to rawVersion and versionName to cleanVersion in status-go derivation - Ports nix/mobile/ios/install-pods-and-status-go.sh to Nix sub-shells - Moves adjustment of `inotify/max_user_watches` out into `scripts/inotify_fix.sh` - Makes iOS builds use the Nix version of Fastlane Signed-off-by: Jakub Sokołowski <jakub@status.im>
2019-11-29 10:20:08 +00:00
keep: ['FASTLANE_DISABLE_COLORS', 'APK_PATHS', 'GOOGLE_PLAY_JSON_KEY'],
attr: 'shells.fastlane'
)
}
}
def uploadToSauceLabs() {
def changeId = utils.changeId()
if (changeId != null) {
env.SAUCE_LABS_NAME = "${changeId}.apk"
} else {
def pkg = utils.pkgFilename(env.BUILD_TYPE, 'apk', 'x86')
env.SAUCE_LABS_NAME = "${pkg}"
}
withCredentials([
usernamePassword(
credentialsId: 'sauce-labs-api',
usernameVariable: 'SAUCE_USERNAME',
passwordVariable: 'SAUCE_ACCESS_KEY'
),
]) {
nix.shell(
'fastlane android saucelabs',
keep: [
'FASTLANE_DISABLE_COLORS', 'APK_PATHS',
'SAUCE_ACCESS_KEY', 'SAUCE_USERNAME', 'SAUCE_LABS_NAME'
],
major nix refactor Changes: - Adds a new `nix-gc` Makefile target for removing old packages - Moves all `nix/*.sh` files to `nix/scripts/*.sh` to make things more tidy - Renames `TARGET_OS` into `TARGET` and makes it effective only with `nix/scripts/shell.sh` - Renames `target-os` Nix argument to just `target` and makes it effective only with `shell.nix` - Drops `IN_CI_ENVIRONMENT` env variable which was useless - Drops use of `target-os` argument outside of `shell.nix` (with few exceptions, but just in naming) - `nix/platform.nix` has been made obsolete and removed - Moves the definition of all major targets to `nix/targets.nix` - Moves the definition of all major shells to `nix/shells.nix` - Makes `default.nix` and `shell.nix` just thin wrappers around `nix/default.nix` - `nix/nixpkgs-bootstrap.nix` has been moved to `nix/pkgs.nix` - All package and tool overrides have been moved to `nix/pkgs.nix` - Explicit passing of contents of `pkgs` has been removed in favor of `callPackage` doing it for us - `nix/bootstrapped-shell.nix` has been moved to `nix/tools/mkShell.nix` - A new `mergeSh` tool has been added to `pkgs` from `nix/tools/mergeSh.nix` - This tool is used to merge shells created using `mkShell` - `mobile/targets/jsbundle.nix` has been moved to `mobile/android/jsbundle/default.nix` - Moves `status-go` version sanitization to `nix/status-go/utils.nix` - Renames version to rawVersion and versionName to cleanVersion in status-go derivation - Ports nix/mobile/ios/install-pods-and-status-go.sh to Nix sub-shells - Moves adjustment of `inotify/max_user_watches` out into `scripts/inotify_fix.sh` - Makes iOS builds use the Nix version of Fastlane Signed-off-by: Jakub Sokołowski <jakub@status.im>
2019-11-29 10:20:08 +00:00
attr: 'shells.fastlane',
pure: false
)
}
return env.SAUCE_LABS_NAME
}
def uploadToDiawi() {
withCredentials([
string(credentialsId: 'diawi-token', variable: 'DIAWI_TOKEN'),
]) {
nix.shell(
'fastlane android upload_diawi',
keep: ['FASTLANE_DISABLE_COLORS', 'APK_PATHS', 'DIAWI_TOKEN'],
major nix refactor Changes: - Adds a new `nix-gc` Makefile target for removing old packages - Moves all `nix/*.sh` files to `nix/scripts/*.sh` to make things more tidy - Renames `TARGET_OS` into `TARGET` and makes it effective only with `nix/scripts/shell.sh` - Renames `target-os` Nix argument to just `target` and makes it effective only with `shell.nix` - Drops `IN_CI_ENVIRONMENT` env variable which was useless - Drops use of `target-os` argument outside of `shell.nix` (with few exceptions, but just in naming) - `nix/platform.nix` has been made obsolete and removed - Moves the definition of all major targets to `nix/targets.nix` - Moves the definition of all major shells to `nix/shells.nix` - Makes `default.nix` and `shell.nix` just thin wrappers around `nix/default.nix` - `nix/nixpkgs-bootstrap.nix` has been moved to `nix/pkgs.nix` - All package and tool overrides have been moved to `nix/pkgs.nix` - Explicit passing of contents of `pkgs` has been removed in favor of `callPackage` doing it for us - `nix/bootstrapped-shell.nix` has been moved to `nix/tools/mkShell.nix` - A new `mergeSh` tool has been added to `pkgs` from `nix/tools/mergeSh.nix` - This tool is used to merge shells created using `mkShell` - `mobile/targets/jsbundle.nix` has been moved to `mobile/android/jsbundle/default.nix` - Moves `status-go` version sanitization to `nix/status-go/utils.nix` - Renames version to rawVersion and versionName to cleanVersion in status-go derivation - Ports nix/mobile/ios/install-pods-and-status-go.sh to Nix sub-shells - Moves adjustment of `inotify/max_user_watches` out into `scripts/inotify_fix.sh` - Makes iOS builds use the Nix version of Fastlane Signed-off-by: Jakub Sokołowski <jakub@status.im>
2019-11-29 10:20:08 +00:00
attr: 'shells.fastlane',
pure: false
)
}
diawiUrl = readFile "${env.WORKSPACE}/fastlane/diawi.out"
return diawiUrl
}
def coverage() {
withCredentials([
string(credentialsId: 'coveralls-status-react-token', variable: 'COVERALLS_REPO_TOKEN'),
]) {
nix.shell(
'make coverage',
keep: ['COVERALLS_REPO_TOKEN', 'COVERALLS_SERVICE_NAME', 'COVERALLS_SERVICE_JOB_ID']
)
}
}
return this