diff --git a/Jenkinsfile b/Jenkinsfile index 8fcaf13..27ba812 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -21,8 +21,8 @@ // Load Jenkins shared libraries common to all projects def libLazy = [ - remote: 'https://code.in.digital-me.nl/git/DEVops/JenkinsLibLazy.git', - branch: 'master', + remote: 'https://github.com/digital-me/jenkins-lib-lazy.git', + branch: 'stable', credentialsId: null, ] @@ -38,7 +38,7 @@ // Load Jenkins shared libraries to customize this project def libCustom = [ remote: 'ssh://git@code.in.digital-me.nl:2222/DEVops/JenkinsLibCustom.git', - branch: 'master', + branch: 'stable', credentialsId: 'bot-ci-dgm-rsa', ] @@ -63,7 +63,7 @@ lazyConfig( name: 'DummyAnd', env: [ RELEASE: false, ], - noPoll: '(.+_.+|acceptance|production)', // Don't poll private nor deploy branches + noPoll: '(.+_.+|acceptance|production)', // Avoid automatic indexing for release and private branches ) // Define lazyStages @@ -72,6 +72,14 @@ onlyif = (! deployBranches.contains(lazyConfig['branch']) ) tasks = [ run: { + def currentVersion = androidVersion() + currentBuild.displayName = "#${env.BUILD_NUMBER} ${currentVersion.string}-${currentVersion.number}" + // Try to see if we can still merge the deploy branches + deployBranches.each { deployBranch -> + gitMerge(workingBranch, deployBranch) + } + // Go back to working branch for validation + sh("git checkout ${workingBranch}") fastLane('android', 'test') }, on: 'android', @@ -105,37 +113,39 @@ tasks = [ run: { def currentVersion = androidVersion() + + // Define next version based on optional input + def nextVersion = [ string: currentVersion.string, number: currentVersion.number + 1 ] + if (env.lazyInput) { + nextVersion = [ string: env.lazyInput, number: nextVersion.number ] + } + gitAuth('bot-ci-dgm', { - // Define next version based on optional input - def nextVersion = [ string: currentVersion.string, number: currentVersion.number + 1 ] - if (env.lazyInput) { - nextVersion = [ string: env.lazyInput, number: nextVersion.number ] + // Refresh each deploy branches with changes from the working branch + deployBranches.each { deployBranch -> + gitMerge(workingBranch, deployBranch) + gitPush(remote, deployBranch) } - // Refresh latest changelogs and bump version in working branch before deploying + // Tag the working branch sh("git checkout ${workingBranch}") + gitTag("${currentVersion.string}-${currentVersion.number}", remote) + + // Refresh latest changelogs and bump version in working branch before deploying fastChangeLogs(nextVersion.number, 'android') androidVersion(nextVersion) gitCommit("Provide changelogs for version ${nextVersion.number}", 'fastlane/metadata/android') gitCommit("Update version to ${nextVersion.string}-${nextVersion.number}", 'app/build.gradle') - // Refresh each deploy branches with changes from the working branch - try { - deployBranches.each { deployBranch -> - gitMerge(workingBranch, deployBranch) - gitPush(remote, deployBranch) - } - } finally { // Publish and tag the working branch with latest changelogs and version anyway - gitPush(remote, workingBranch) - gitTag("${currentVersion.string}-${currentVersion.number}", remote) - } + // Publish working branch with latest changelogs and next version + gitPush(remote, workingBranch) }) }, on: 'android', ] } -// From systemtest to production, only for release branches +// From alpha to beta, only for deploy branches lazyStage { name = 'alpha' onlyif = ( deployBranches.contains(lazyConfig['branch']) ) @@ -169,6 +179,23 @@ on: 'android', ] } + +lazyStage { + name = 'beta_crash' + onlyif = (! deployBranches.contains(lazyConfig['branch']) && lazyConfig['branch'] != workingBranch && lazyConfig.env.RELEASE ) + input = 'Promote to Crashlytics Beta users?' + tasks = [ + pre: { + unarchive(mapping:["${buildDir}/" : '.']) + }, + run: { + if ( !lazyConfig.env.DRYRUN ) { + fastLane('android', 'beta_crash', "fl_branch:\"${lazyConfig['branch']}\"") + } + }, + on: 'android', + ] +} /* lazyStage { name = 'production' diff --git a/app/build.gradle b/app/build.gradle index eceb733..7c8d0a0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -66,14 +66,36 @@ flavorDimensions "env" - productFlavors { - acc { - dimension "env" - applicationIdSuffix ".acc" + productFlavors { // May need to match branch name, passed by Jenkins PL as environment variable named LAZY_BRANCH + systemtest { + resValue "string", "app_name", "DummyAnd STst" + applicationIdSuffix ".stst" +// manifestPlaceholders = [errorBaseUrl : "https://systemtest-card.testonly.digital-me.nl/card", +// cardNodeBaseUrl: "https://systemtest-card.testonly.digital-me.nl/card", +// userNodeBaseUrl: "https://systemtest-user.testonly.digital-me.nl/user"] } - prd { - dimension "env" + acceptance { + resValue "string", "app_name", "DummyAnd Acc" + applicationIdSuffix ".acc" +// manifestPlaceholders = [errorBaseUrl : "https://card.dolden.net/card", +// cardNodeBaseUrl: "https://card.dolden.net/card", +// userNodeBaseUrl: "https://user.dolden.net/user"] + } + + dev2 { + resValue "string", "app_name", "DummyAnd Dev2" + applicationIdSuffix ".dev2" +// manifestPlaceholders = [errorBaseUrl : "https://dev2-card.testonly.digital-me.nl/card", +// cardNodeBaseUrl: "https://dev2-card.testonly.digital-me.nl/card", +// userNodeBaseUrl: "https://dev2-user.testonly.digital-me.nl/user"] + } + + production { + resValue "string", "app_name", "DummyAnd" +// manifestPlaceholders = [errorBaseUrl : "https://card.digital-me.nl/card", +// cardNodeBaseUrl: "https://card.digital-me.nl/card", +// userNodeBaseUrl: "https://user.digital-me.nl/user"] } } @@ -101,6 +123,11 @@ } } +repositories { + maven { url 'https://maven.fabric.io/public' } + mavenCentral() +} + dependencies { //compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' diff --git a/app/src/acceptance/res/drawable-hdpi/dummy_icon.png b/app/src/acceptance/res/drawable-hdpi/dummy_icon.png new file mode 100644 index 0000000..c73f81a --- /dev/null +++ b/app/src/acceptance/res/drawable-hdpi/dummy_icon.png Binary files differ diff --git a/app/src/acceptance/res/drawable-ldpi/dummy_icon.png b/app/src/acceptance/res/drawable-ldpi/dummy_icon.png new file mode 100644 index 0000000..1309f2e --- /dev/null +++ b/app/src/acceptance/res/drawable-ldpi/dummy_icon.png Binary files differ diff --git a/app/src/acceptance/res/drawable-mdpi/dummy_icon.png b/app/src/acceptance/res/drawable-mdpi/dummy_icon.png new file mode 100644 index 0000000..7c5985e --- /dev/null +++ b/app/src/acceptance/res/drawable-mdpi/dummy_icon.png Binary files differ diff --git a/app/src/acceptance/res/drawable-xhdpi/dummy_icon.png b/app/src/acceptance/res/drawable-xhdpi/dummy_icon.png new file mode 100644 index 0000000..82f2105 --- /dev/null +++ b/app/src/acceptance/res/drawable-xhdpi/dummy_icon.png Binary files differ diff --git a/app/src/acceptance/res/drawable-xxhdpi/dummy_icon.png b/app/src/acceptance/res/drawable-xxhdpi/dummy_icon.png new file mode 100644 index 0000000..926a90e --- /dev/null +++ b/app/src/acceptance/res/drawable-xxhdpi/dummy_icon.png Binary files differ diff --git a/app/src/acceptance/res/drawable-xxxhdpi/dummy_icon.png b/app/src/acceptance/res/drawable-xxxhdpi/dummy_icon.png new file mode 100644 index 0000000..72237c0 --- /dev/null +++ b/app/src/acceptance/res/drawable-xxxhdpi/dummy_icon.png Binary files differ diff --git a/app/src/acceptance/res/values/colors.xml b/app/src/acceptance/res/values/colors.xml new file mode 100644 index 0000000..ef36fad --- /dev/null +++ b/app/src/acceptance/res/values/colors.xml @@ -0,0 +1,6 @@ + + + #21A384 + #14705A + #FF4081 + diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 6b7c22b..c383bb9 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -4,7 +4,7 @@ diff --git a/app/src/main/gen/nl/digital_me/dummyandroidapp/BuildConfig.java b/app/src/main/gen/nl/digital_me/dummyandroidapp/BuildConfig.java new file mode 100644 index 0000000..a519ffd --- /dev/null +++ b/app/src/main/gen/nl/digital_me/dummyandroidapp/BuildConfig.java @@ -0,0 +1,6 @@ +/** Automatically generated file. DO NOT MODIFY */ +package nl.digital_me.dummyandroidapp; + +public final class BuildConfig { + public final static boolean DEBUG = true; +} \ No newline at end of file diff --git a/app/src/main/project.properties b/app/src/main/project.properties new file mode 100644 index 0000000..916037e --- /dev/null +++ b/app/src/main/project.properties @@ -0,0 +1,14 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system edit +# "ant.properties", and override values to adapt the script to your +# project structure. +# +# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): +#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt + +# Project target. +target=android-23 diff --git a/app/src/main/res/mipmap-hdpi/dummy_icon.png b/app/src/main/res/mipmap-hdpi/dummy_icon.png new file mode 100644 index 0000000..177f3d9 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/dummy_icon.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png deleted file mode 100644 index cde69bc..0000000 --- a/app/src/main/res/mipmap-hdpi/ic_launcher.png +++ /dev/null Binary files differ diff --git a/app/src/main/res/mipmap-ldpi/dummy_icon.png b/app/src/main/res/mipmap-ldpi/dummy_icon.png new file mode 100644 index 0000000..bb2a1b2 --- /dev/null +++ b/app/src/main/res/mipmap-ldpi/dummy_icon.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/dummy_icon.png b/app/src/main/res/mipmap-mdpi/dummy_icon.png new file mode 100644 index 0000000..1fc4dab --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/dummy_icon.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png deleted file mode 100644 index c133a0c..0000000 --- a/app/src/main/res/mipmap-mdpi/ic_launcher.png +++ /dev/null Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/dummy_icon.png b/app/src/main/res/mipmap-xhdpi/dummy_icon.png new file mode 100644 index 0000000..b427e03 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/dummy_icon.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png deleted file mode 100644 index bfa42f0..0000000 --- a/app/src/main/res/mipmap-xhdpi/ic_launcher.png +++ /dev/null Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/dummy_icon.png b/app/src/main/res/mipmap-xxhdpi/dummy_icon.png new file mode 100644 index 0000000..2393d8b --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/dummy_icon.png Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png deleted file mode 100644 index 324e72c..0000000 --- a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +++ /dev/null Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/dummy_icon.png b/app/src/main/res/mipmap-xxxhdpi/dummy_icon.png new file mode 100644 index 0000000..9d385a9 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/dummy_icon.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png deleted file mode 100644 index aee44e1..0000000 --- a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +++ /dev/null Binary files differ diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ad4735d..e934a36 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,5 +1,4 @@ - DummyAnd Settings Hello World from section: %1$d Type your text here diff --git a/build.gradle b/build.gradle index e5844dc..54e858d 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ } dependencies { // https://jcenter.bintray.com/com/android/tools/build/gradle - classpath 'com.android.tools.build:gradle:3.0.1' + classpath 'com.android.tools.build:gradle:3.2.0' } } @@ -23,9 +23,9 @@ //This block encapsulates custom properties and makes them available to all //modules in the project. ext { - compileSdkVersion = 27 - buildToolsVersion = "27.0.3" - supportLibVersion = "27.0.2" + compileSdkVersion = 28 + buildToolsVersion = "28.0.2" + supportLibVersion = "28.0.0" } task clean(type: Delete) { diff --git a/fastlane/.gitignore b/fastlane/.gitignore new file mode 100644 index 0000000..1de5f95 --- /dev/null +++ b/fastlane/.gitignore @@ -0,0 +1,2 @@ +/README.md +/report.xml \ No newline at end of file diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 51453d9..d448d16 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -16,26 +16,125 @@ default_platform :android platform :android do - before_all do + + desc "Extract Application Id from gradle file" + def get_application_id(flavor = nil, path = '../app/build.gradle', constant_name = 'applicationId') + application_id = nil + application_id_suffix = nil + toggle_flavors = false + current_flavor = nil + unless File.file?(path) + UI.message(" -> No file exists at path: (#{path})!") + return application_id + end + begin + file = File.new(path, 'r') + while (line = file.gets) + next unless line.include? constant_name + components = line.strip.split(' ') + application_id = components[components.length - 1].tr("\"", '') + UI.message("#{constant_name} = #{application_id}") + break + end + if flavor + file.each do |line| + if line[/^(#.*)?$/] + next + end + #UI.message("Line = #{line.tr("\n",'')}") + if toggle_flavors + current_flavor = line[/(?=\s*)\w+(?=\s+\{)/] + if ! current_flavor + break + end + #UI.message("Flavor = #{current_flavor}") + toggle_flavors = false + next + end + if current_flavor == flavor and line.include? "#{constant_name}Suffix" + components = line.strip.split(' ') + application_id_suffix = components[components.length - 1].tr("\"", '') + UI.message("#{constant_name}Suffix = #{application_id_suffix}") + next + end + if line[/\s*}/] + if current_flavor + current_flavor = nil + toggle_flavors = true + next + end + if toggle_flavors + break + end + next + end + if line[/(?=\s*)productFlavors(?=\s+\{)/] + toggle_flavors = true + next + end + end + end + file.close + rescue => err + UI.error("An exception occurred while reading the gradle file: #{err}") + err + end + return "#{application_id}#{application_id_suffix}" + end + + desc "Define flavor name for deploy branch" + def getFlavorName(options) + flavor = nil + if options and options[:fl_branch] and ! options[:fl_branch][/.*_.*/] + # Use option if provided + flavor = options[:fl_branch] + else + # Fallback on environment variable if any + if ENV['BRANCH_NAME'] and ! ENV['BRANCH_NAME'][/.*_.*/] + flavor = ENV['BRANCH_NAME'] + end + end + if flavor == 'master' + flavor = 'production' + end + if flavor == nil or flavor == '' + # Choose default flavor + flavor = 'dev2' + end + return flavor + end + + desc "Define package name for a branch" + def getPackageName(options = nil) + return get_application_id(getFlavorName(options)) + end + + before_all do |lane, options| # ENV["SLACK_URL"] = "https://hooks.slack.com/services/..." end + desc "Display infos about the app" + lane :info do |options| + UI.message("App Flavor = #{getFlavorName(options)}") + UI.message("App ID = #{getPackageName(options)}") + end + desc "Runs all the tests" - lane :test do + lane :test do |options| gradle(task: "test") end desc "Build the apk" - lane :build do + lane :build do |options| gradle( task: "clean assemble", build_type: 'Release', - flavor: "prd", + flavor: "#{getFlavorName(options)}", ) end desc "Bump version code/build number" - private_lane :bump do + private_lane :bump do |options| increment_version_code( var_name: "versionCode|versionBuild", verbose: true, @@ -43,7 +142,7 @@ end desc "Tag as a new version" - private_lane :tag do + private_lane :tag do |options| git_commit( path: "app/build.gradle", message: "Increment version code to #{lane_context[SharedValues::VERSION_CODE]} for next release", @@ -59,7 +158,7 @@ end desc "Build and deploy the apk for Alpha testing in Google Play store" - lane :deploy_alpha do + lane :deploy_alpha do |options| bump gradle( task: "clean assemble", @@ -81,8 +180,8 @@ message: "Provide changelogs for this version", ) supply( - apk: 'app/build/outputs/apk/prd/release/app-prd-release.apk', - mapping: 'app/build/outputs/apk/prd/release/mapping.txt', + apk: "app/build/outputs/apk/#{getFlavorName(options)}/release/app-#{getFlavorName(options)}-release.apk", + mapping: "app/build/outputs/apk/#{getFlavorName(options)}/release/mapping.txt", track: 'alpha', skip_upload_apk: false, skip_upload_metadata: false, @@ -93,7 +192,7 @@ end desc "Update metadata only, including images and screenshots" - lane :deploy_metadata do + lane :deploy_metadata do |options| supply( skip_upload_apk: true, skip_upload_metadata: false, @@ -103,30 +202,30 @@ end desc "Submit a new build to Crashlytics Beta" - lane :beta_crash do + lane :beta_crash do |options| gradle(task: "assembleRelease") - crashlytics - - # sh "your_script.sh" - # You can also use other beta testing services here + crashlytics( + api_token: "b439e4099424e0f33cdab4e7b689b60c4bc3a5d2", + build_secret: "ecffdd52c995054f79161c3570ed769f2bacf2dd3082e2aba7489b147c29ce7d" + ) end desc "Deploy a new version to the Google Play" - lane :alpha do + lane :alpha do |options| supply( - apk: 'app/build/outputs/apk/prd/release/app-prd-release.apk', - mapping: 'app/build/outputs/apk/prd/release/mapping.txt', + apk: "app/build/outputs/apk/#{getFlavorName(options)}/release/app-#{getFlavorName(options)}-release.apk", + mapping: "app/build/outputs/apk/#{getFlavorName(options)}/release/mapping.txt", track: 'alpha', skip_upload_apk: false, skip_upload_metadata: false, skip_upload_images: false, skip_upload_screenshots: false, - package_name: "nl.digital_me.dummyandroidapp", + package_name: "#{getPackageName(options)}", ) end desc "Deploy a new version to the Google Play" - lane :beta do + lane :beta do |options| supply( track: 'alpha', track_promote_to: 'beta', @@ -134,12 +233,12 @@ skip_upload_metadata: true, skip_upload_images: true, skip_upload_screenshots: true, - package_name: "nl.digital_me.dummyandroidapp", + package_name: "#{getPackageName(options)}", ) end desc "Deploy a new version to the Google Play" - lane :production do + lane :production do |options| supply( track: 'beta', track_promote_to: 'production', @@ -147,13 +246,13 @@ skip_upload_metadata: true, skip_upload_images: true, skip_upload_screenshots: true, - package_name: "nl.digital_me.dummyandroidapp", + package_name: "#{getPackageName(options)}", ) end # You can define as many lanes as you want - after_all do |lane| + after_all do |lane, options| # This block is called, only if the executed lane was successful # slack( diff --git a/fastlane/README.md b/fastlane/README.md deleted file mode 100644 index 662694d..0000000 --- a/fastlane/README.md +++ /dev/null @@ -1,67 +0,0 @@ -fastlane documentation -================ -# Installation - -Make sure you have the latest version of the Xcode command line tools installed: - -``` -xcode-select --install -``` - -## Choose your installation method: - - - - - - - - - - - - - - -
Homebrew -Installer Script -Rubygems -
macOSmacOSmacOS or Linux with Ruby 2.0.0 or above
brew cask install fastlaneDownload the zip file. Then double click on the install script (or run it in a terminal window).sudo gem install fastlane -NV
-# Available Actions -## Android -### android test -``` -fastlane android test -``` -Runs all the tests -### android build -``` -fastlane android build -``` -Build the apk -### android deploy_alpha -``` -fastlane android deploy_alpha -``` -Build and deploy the apk for Alpha testing in Google Play store -### android graphics_only -``` -fastlane android graphics_only -``` -Update images and screenshots only -### android beta -``` -fastlane android beta -``` -Submit a new Beta Build to Crashlytics Beta -### android deploy -``` -fastlane android deploy -``` -Deploy a new version to the Google Play - ----- - -This README.md is auto-generated and will be re-generated every time [fastlane](https://fastlane.tools) is run. -More information about fastlane can be found on [fastlane.tools](https://fastlane.tools). -The documentation of fastlane can be found on [docs.fastlane.tools](https://docs.fastlane.tools). diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f69806e..07e5162 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Thu Oct 26 16:21:57 CET 2017 +#Fri Oct 05 14:15:14 CEST 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip