diff --git a/Jenkinsfile b/Jenkinsfile index 0241cd8..d54e534 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -58,8 +58,11 @@ def workingBranch = 'master' def deployBranches = [ 'acceptance', 'production', ] -// Define the directory where the package will be build -def buildDir = 'app/build/outputs/apk' +// Define the directory where the package (bundle) will be build +def buildDir = 'app/build/outputs/bundle' +// Define the directory where the package (apk) will be build. +// Fabric Crashlytics / Firebase App Distribution only support APKs as of June 2020 +def buildDirApk = 'app/build/outputs/apk' // Initialize lazyConfig for this pipeline lazyConfig( @@ -133,7 +136,11 @@ currentBuild.displayName = "#${env.BUILD_NUMBER} ${currentVersion.string}-${currentVersion.number}" }, run: { - fastLane('android', 'build') + // Fabric Crashlytics / Firebase App Distribution only support APKs as of June 2020 + if (! deployBranches.contains(lazyConfig['branch']) && lazyConfig['branch'] != workingBranch && lazyConfig.env.RELEASE ) + fastLane('android', 'build_apk') + else + fastLane('android', 'build') }, args: "-v /opt/android:/opt/android" + " -v /opt/certificates:/opt/certificates" @@ -143,7 +150,12 @@ on: 'android', post: { junit(testResults: 'fastlane/report.xml,**/build/test-results/*/*.xml', allowEmptyResults: true) - archiveArtifacts(artifacts: "${buildDir}/**", allowEmptyArchive: false) + + // Fabric Crashlytics / Firebase App Distribution only support APKs as of June 2020 + if (! deployBranches.contains(lazyConfig['branch']) && lazyConfig['branch'] != workingBranch && lazyConfig.env.RELEASE ) + archiveArtifacts(artifacts: "${buildDirApk}/**", allowEmptyArchive: false) + else + archiveArtifacts(artifacts: "${buildDir}/**", allowEmptyArchive: false) }, ] } @@ -153,7 +165,10 @@ onlyif = (! deployBranches.contains(lazyConfig['branch']) && lazyConfig['branch'] != workingBranch && lazyConfig.env.RELEASE ) tasks = [ pre: { - unarchive(mapping:["${buildDir}/" : '.']) + if (! deployBranches.contains(lazyConfig['branch']) && lazyConfig['branch'] != workingBranch && lazyConfig.env.RELEASE ) + unarchive(mapping:["${buildDirApk}/" : '.']) + else + unarchive(mapping:["${buildDir}/" : '.']) }, run: { if ( !lazyConfig.env.DRYRUN ) { @@ -225,7 +240,10 @@ input = 'Deploy to internal testers?' tasks = [ pre: { - unarchive(mapping:["${buildDir}/" : '.']) + if (! deployBranches.contains(lazyConfig['branch']) && lazyConfig['branch'] != workingBranch && lazyConfig.env.RELEASE ) + unarchive(mapping:["${buildDirApk}/" : '.']) + else + unarchive(mapping:["${buildDir}/" : '.']) }, run: { if ( !lazyConfig.env.DRYRUN ) { @@ -249,7 +267,10 @@ input = 'Deploy to alpha users?' tasks = [ pre: { - unarchive(mapping:["${buildDir}/" : '.']) + if (! deployBranches.contains(lazyConfig['branch']) && lazyConfig['branch'] != workingBranch && lazyConfig.env.RELEASE ) + unarchive(mapping:["${buildDirApk}/" : '.']) + else + unarchive(mapping:["${buildDir}/" : '.']) }, run: { if ( !lazyConfig.env.DRYRUN ) { @@ -276,7 +297,10 @@ input = 'Promote to beta users?' tasks = [ pre: { - unarchive(mapping:["${buildDir}/" : '.']) + if (! deployBranches.contains(lazyConfig['branch']) && lazyConfig['branch'] != workingBranch && lazyConfig.env.RELEASE ) + unarchive(mapping:["${buildDirApk}/" : '.']) + else + unarchive(mapping:["${buildDir}/" : '.']) }, run: { if ( !lazyConfig.env.DRYRUN ) { diff --git a/fastlane/Fastfile b/fastlane/Fastfile index c3cd799..97815be 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -172,7 +172,7 @@ end desc "Build the apk" - lane :build do |options| + lane :build_apk do |options| gradle( task: "clean assemble", build_type: 'Release', @@ -180,10 +180,77 @@ ) end + desc "Build the bundle" + lane :build do |options| + gradle( + task: "clean bundle", + build_type: 'Release', + flavor: "#{getFlavorName(options)}", + ) + end + + desc "Bump version code/build number" + private_lane :bump do |options| + increment_version_code( + var_name: "versionCode|versionBuild", + verbose: true, + ) + end + + desc "Tag as a new version" + private_lane :tag do |options| + git_commit( + path: "app/build.gradle", + message: "Increment version code to #{lane_context[SharedValues::VERSION_CODE]} for next release", + ) + add_git_tag( + tag: "#{ENV['VERSION']}-#{lane_context[SharedValues::VERSION_CODE]}", + message: "Create new tag for version #{ENV['VERSION']}-#{lane_context[SharedValues::VERSION_CODE]}", + ) + push_to_git_remote( + local_branch: "HEAD", + remote_branch: "master", + ) + end + + desc "Build and deploy the bundle for Alpha testing in Google Play store" + lane :deploy_alpha do |options| + bump + gradle( + task: "clean bundle", + build_type: 'Release', + ) + sh("cp -vf metadata/android/en-US/changelogs/latest.txt metadata/android/en-US/changelogs/#{lane_context[SharedValues::VERSION_CODE]}.txt") + sh("git add metadata/android/en-US/changelogs/#{lane_context[SharedValues::VERSION_CODE]}.txt") + sh("git add metadata/android/en-US/changelogs/latest.txt") + sh("cp -vf metadata/android/nl-NL/changelogs/latest.txt metadata/android/nl-NL/changelogs/#{lane_context[SharedValues::VERSION_CODE]}.txt") + sh("git add metadata/android/nl-NL/changelogs/#{lane_context[SharedValues::VERSION_CODE]}.txt") + sh("git add metadata/android/nl-NL/changelogs/latest.txt") + git_commit( + path: [ + "fastlane/metadata/android/en-US/changelogs/latest.txt", + "fastlane/metadata/android/en-US/changelogs/#{lane_context[SharedValues::VERSION_CODE]}.txt", + "fastlane/metadata/android/nl-NL/changelogs/latest.txt", + "fastlane/metadata/android/nl-NL/changelogs/#{lane_context[SharedValues::VERSION_CODE]}.txt", + ], + message: "Provide changelogs for this version", + ) + supply( + aab: "app/build/outputs/bundle/#{getFlavorName(options)}Release/app-#{getFlavorName(options)}-release.aab", + mapping: "app/build/outputs/mapping/#{getFlavorName(options)}/release/mapping.txt", + track: 'internal', + skip_upload_aab: false, + skip_upload_metadata: false, + skip_upload_images: true, + skip_upload_screenshots: true, + ) + tag + end + desc "Update metadata only, including images and screenshots" lane :deploy_metadata do |options| supply( - skip_upload_apk: true, + skip_upload_aab: true, skip_upload_metadata: false, skip_upload_images: false, skip_upload_screenshots: false, @@ -214,10 +281,10 @@ desc "Deploy a new internal version to the Google Play" lane :internal do |options| supply( - apk: "app/build/outputs/apk/#{getFlavorName(options)}/release/app-#{getFlavorName(options)}-release.apk", - mapping: "app/build/outputs/apk/#{getFlavorName(options)}/release/mapping.txt", + aab: "app/build/outputs/bundle/#{getFlavorName(options)}Release/app-#{getFlavorName(options)}-release.aab", + mapping: "app/build/outputs/mapping/#{getFlavorName(options)}/release/mapping.txt", track: 'internal', - skip_upload_apk: false, + skip_upload_aab: false, skip_upload_metadata: false, skip_upload_images: false, skip_upload_screenshots: false, @@ -230,7 +297,7 @@ supply( track: 'internal', track_promote_to: 'alpha', - skip_upload_apk: true, + skip_upload_aab: true, skip_upload_metadata: true, skip_upload_images: true, skip_upload_screenshots: true, @@ -244,7 +311,7 @@ supply( track: 'alpha', track_promote_to: 'beta', - skip_upload_apk: true, + skip_upload_aab: true, skip_upload_metadata: true, skip_upload_images: true, skip_upload_screenshots: true, @@ -258,7 +325,7 @@ supply( track: 'beta', track_promote_to: 'production', - skip_upload_apk: true, + skip_upload_aab: true, skip_upload_metadata: true, skip_upload_images: true, skip_upload_screenshots: true,