From 4d49ec9e7a88a869da6c264a7938024d557d44a6 Mon Sep 17 00:00:00 2001 From: MatthewTighe Date: Tue, 7 May 2019 11:48:21 -0700 Subject: [PATCH 1/3] Automate github releases. --- .circleci/config.yml | 6 ++++++ .gitignore | 2 ++ Gemfile.lock | 26 +++++++++++++------------- app/build.gradle | 6 +++++- fastlane/Fastfile | 37 ++++++++++++++++++++++++++++++------- 5 files changed, 56 insertions(+), 21 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index af0dc8012..473462f13 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -79,6 +79,11 @@ reference: name: Decode Android key store command: echo $ANDROID_KEYSTORE | base64 -di > keystore.jks + export_github_release_key: &export_github_release_token + run: + name: Export Github release key + command echo 'export GITHUB_RELEASE_TOKEN="$GITHUB_RELEASE_TOKEN"' >> $BASH_ENV + export_gcloud_key: &export_gcloud_key run: name: Export Google Cloud Service key environment variable @@ -232,6 +237,7 @@ jobs: - *attach_release_workspace - *export_play_key - *decode_play_key + - *export_github_release_token - run: name: Deploy to Play store command: bundle exec fastlane deploy diff --git a/.gitignore b/.gitignore index 95fbb6389..f639ae3f9 100644 --- a/.gitignore +++ b/.gitignore @@ -45,8 +45,10 @@ captures/ # Generated files for deployment app/versionCode.txt +app/versionName.txt fastlane/README.md fastlane/report.xml +fastlane/metadata/android/*/changelogs # External native build folder generated in Android Studio 2.2 and later .externalNativeBuild diff --git a/Gemfile.lock b/Gemfile.lock index 460c71012..379a59e2d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -16,9 +16,9 @@ GEM digest-crc (0.4.1) domain_name (0.5.20180417) unf (>= 0.0.5, < 1.0.0) - dotenv (2.6.0) + dotenv (2.7.2) emoji_regex (1.0.1) - excon (0.62.0) + excon (0.64.0) faraday (0.15.4) multipart-post (>= 1.2, < 3) faraday-cookie_jar (0.0.6) @@ -27,7 +27,7 @@ GEM faraday_middleware (0.13.1) faraday (>= 0.7.4, < 1.0) fastimage (2.1.5) - fastlane (2.116.1) + fastlane (2.122.0) CFPropertyList (>= 2.3, < 4.0.0) addressable (>= 2.3, < 3.0.0) babosa (>= 1.0.2, < 2.0.0) @@ -56,12 +56,12 @@ GEM security (= 0.1.3) simctl (~> 1.6.3) slack-notifier (>= 2.0.0, < 3.0.0) - terminal-notifier (>= 1.6.2, < 2.0.0) + terminal-notifier (>= 2.0.0, < 3.0.0) terminal-table (>= 1.4.5, < 2.0.0) tty-screen (>= 0.6.3, < 1.0.0) tty-spinner (>= 0.8.0, < 1.0.0) word_wrap (~> 1.0.0) - xcodeproj (>= 1.6.0, < 2.0.0) + xcodeproj (>= 1.8.1, < 2.0.0) xcpretty (~> 0.3.0) xcpretty-travis-formatter (>= 0.0.3) gh_inspector (1.1.3) @@ -93,19 +93,19 @@ GEM http-cookie (1.0.3) domain_name (~> 0.5) httpclient (2.8.3) - json (2.1.0) + json (2.2.0) jwt (2.1.0) memoist (0.16.0) mime-types (3.2.2) mime-types-data (~> 3.2015) - mime-types-data (3.2018.0812) + mime-types-data (3.2019.0331) mini_magick (4.5.1) multi_json (1.13.1) multi_xml (0.6.0) multipart-post (2.0.0) nanaimo (0.2.6) naturally (2.2.0) - os (1.0.0) + os (1.0.1) plist (3.5.0) public_suffix (2.0.5) representable (3.0.4) @@ -125,20 +125,20 @@ GEM CFPropertyList naturally slack-notifier (2.3.2) - terminal-notifier (1.8.0) + terminal-notifier (2.0.0) terminal-table (1.8.0) unicode-display_width (~> 1.1, >= 1.1.1) - tty-cursor (0.6.0) + tty-cursor (0.6.1) tty-screen (0.6.5) tty-spinner (0.9.0) tty-cursor (~> 0.6.0) uber (0.1.0) unf (0.1.4) unf_ext - unf_ext (0.0.7.5) - unicode-display_width (1.4.1) + unf_ext (0.0.7.6) + unicode-display_width (1.5.0) word_wrap (1.0.0) - xcodeproj (1.8.1) + xcodeproj (1.9.0) CFPropertyList (>= 2.3.3, < 4.0) atomos (~> 0.1.3) claide (>= 1.0.2, < 2.0) diff --git a/app/build.gradle b/app/build.gradle index 350ec3c3b..9879e8e66 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -25,7 +25,7 @@ android { minSdkVersion 21 targetSdkVersion 28 versionCode 61 - versionName "2.5.7" + versionName "2.5.8" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary = true @@ -111,6 +111,10 @@ task reportVersionCode { new File("$projectDir/versionCode.txt").text = "$project.android.defaultConfig.versionCode" } +task reportVersionName { + new File("$projectDir/versionName.txt").text = "$project.android.defaultConfig.versionName" +} + task ktlint(type: JavaExec, group: "verification") { description = "Check Kotlin code style." classpath = configurations.ktlint diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 50ba18092..4eef943a3 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -10,31 +10,54 @@ # https://docs.fastlane.tools/plugins/available-plugins # -# Uncomment the line if you want fastlane to automatically update itself -# update_fastlane +update_fastlane default_platform(:android) platform :android do + desc "Update changelogs based on latest version code" lane :update_changelogs do gradle(task: "reportVersionCode") - versionCode = File.read("../app/versionCode.txt") + version_code = File.read("../app/versionCode.txt") changelog = changelog_from_git_commits(merge_commit_filtering: "exclude_merges", pretty: "- %s") - changelogsDir = "metadata/android/en-US/changelogs" - changelogFile = changelogsDir + "/" + versionCode + ".txt" + changelogs_dir = "metadata/android/en-US/changelogs" + changelog_file = changelogs_dir + "/" + version_code + ".txt" - sh("mkdir", "-p", changelogsDir) - File.open(changelogFile, 'w') do |file| + sh("mkdir", "-p", changelogs_dir) + File.open(changelog_file, 'w') do |file| file.write changelog end end + desc "Release to Github" + lane :github_release do + gradle(task: "reportVersionCode") + version_code = File.read("../app/versionCode.txt") + changelogs_dir = "metadata/android/en-US/changelogs" + changelog_file = changelogs_dir + "/" + version_code + ".txt" + + gradle(task: "reportVersionName") + version_name = File.read("../app/versionName.txt") + release_name = "v" + version_name + + set_github_release( + repository_name: "CypherpunkArmory/UserLAnd", + api_token: ENV["GITHUB_RELEASE_TOKEN"], + name: release_name, + tag_name: release_name, + description: (File.read(changelog_file) rescue "No changelog provided"), + commitish: "releases", + upload_assets: ["app/build/outputs/apk/release/app-release.apk"] + ) + end + desc "Deploy a new version to the Google Play" lane :deploy do update_changelogs + github_release supply(apk: "app/build/outputs/apk/release/app-release.apk") end end From 6f58b92e28a9418bb457441b2d7a1d18b2b7da6b Mon Sep 17 00:00:00 2001 From: MatthewTighe Date: Tue, 7 May 2019 11:50:37 -0700 Subject: [PATCH 2/3] Fix circleci variable. --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 473462f13..0e3ebd514 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -79,7 +79,7 @@ reference: name: Decode Android key store command: echo $ANDROID_KEYSTORE | base64 -di > keystore.jks - export_github_release_key: &export_github_release_token + export_github_release_token: &export_github_release_token run: name: Export Github release key command echo 'export GITHUB_RELEASE_TOKEN="$GITHUB_RELEASE_TOKEN"' >> $BASH_ENV From 6c4ffb884daacf42a5b102e5c595154b52dfb0a3 Mon Sep 17 00:00:00 2001 From: MatthewTighe Date: Tue, 7 May 2019 14:00:23 -0700 Subject: [PATCH 3/3] Fix command. --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 0e3ebd514..bdb0e305c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -82,7 +82,7 @@ reference: export_github_release_token: &export_github_release_token run: name: Export Github release key - command echo 'export GITHUB_RELEASE_TOKEN="$GITHUB_RELEASE_TOKEN"' >> $BASH_ENV + command: echo 'export GITHUB_RELEASE_TOKEN="$GITHUB_RELEASE_TOKEN"' >> $BASH_ENV export_gcloud_key: &export_gcloud_key run: