diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml new file mode 100644 index 00000000..866d4d48 --- /dev/null +++ b/.github/workflows/create-release.yml @@ -0,0 +1,25 @@ +on: + push: + tags: + - "v*" + +name: Create Release + +jobs: + build: + name: Create Release + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4.1.7 + - name: Create Release + id: create_release + uses: actions/create-release@v1.1.4 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + body_path: fastlane/metadata/android/en-US/changelogs/${{ github.ref }}.txt + draft: false + prerelease: false diff --git a/.github/workflows/deploy-production.yml b/.github/workflows/deploy-production.yml new file mode 100644 index 00000000..ca62d146 --- /dev/null +++ b/.github/workflows/deploy-production.yml @@ -0,0 +1,38 @@ +name: Deploy Production + +on: workflow_dispatch + +jobs: + production: + runs-on: ubuntu-latest + permissions: + contents: write + if: github.ref == 'refs/heads/main' + steps: + - uses: actions/checkout@v4.1.7 + with: + ssh-key: ${{ secrets.RELEASE_SSH_KEY }} + - name: Set up Ruby + uses: ruby/setup-ruby@v1.180.1 + - name: Set up Java + uses: actions/setup-java@v4.2.1 + with: + distribution: 'zulu' + java-version: '17' + - name: Setup build dependencies + run: make deps + - name: Configure Git user + run: | + git config user.name "jocmp" + git config user.email "9521010+jocmp@users.noreply.github.com" + - name: Bump version + run: bumpver update + - name: Deploy App to Production + env: + ENCODED_GOOGLE_PLAY_CREDENTIALS: ${{ secrets.ENCODED_GOOGLE_PLAY_CREDENTIALS }} + ENCODED_GOOGLE_SERVICES: ${{ secrets.ENCODED_GOOGLE_SERVICES }} + ENCODED_RELEASE_KEYSTORE: ${{ secrets.ENCODED_RELEASE_KEYSTORE }} + ENCODED_SECRETS_PROPERTIES: ${{ secrets.ENCODED_SECRETS_PROPERTIES }} + run: make deploy-production + - name: Sync versioning to Main + run: git push --follow-tags diff --git a/.gitignore b/.gitignore index 9a2e7046..128c85ee 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,9 @@ local.properties fastlane/report.xml app/release/ app/google-services.json + +# Secrets +google-play-service-account.json +app/google-services.json +secrets.properties +release.keystore diff --git a/Makefile b/Makefile index d1c8d785..185a5a67 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,26 @@ SHELL:=/usr/bin/env bash FASTLANE ?= bundle exec fastlane -.PHONY: test +.PHONY: test release-secrets deploy-production + +.PHONY: deps +deps: + bundle install + pip install bumpver==2023.1129 + +.PHONY: changelog +changelog: + ./scripts/changelog test: $(FASTLANE) test + +deploy-production: release-secrets + $(FASTLANE) production + +.SILENT: +release-secrets: + echo ${ENCODED_GOOGLE_PLAY_CREDENTIALS} | base64 --decode > ./google-play-service-account.json + echo ${ENCODED_GOOGLE_SERVICES} | base64 --decode > ./app/google-services.json + echo ${ENCODED_RELEASE_KEYSTORE} | base64 --decode > ./release.keystore + echo ${ENCODED_SECRETS_PROPERTIES} | base64 --decode > ./secrets.properties diff --git a/README.md b/README.md index 3cf46ec9..380919f0 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,10 @@ # Capy Reader +[![CalVer v2024.06.1000][img_version]][url_version] + _A smallish RSS reader for Feedbin_ + +[img_version]: https://img.shields.io/static/v1.svg?label=CalVer&message=v2024.06.1000&color=blue +[url_version]: https://github.com/jocmp/capyreader diff --git a/app/build.gradle.kts b/app/build.gradle.kts index f347c051..835e917e 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,4 +1,5 @@ import com.android.build.gradle.internal.tasks.factory.dependsOn +import java.util.Properties plugins { id("com.android.application") @@ -8,6 +9,12 @@ plugins { id("com.google.firebase.crashlytics") } +val secrets = Properties() + +if (rootProject.file("secrets.properties").exists()) { + secrets.load(rootProject.file("secrets.properties").inputStream()) +} + android { namespace = "com.jocmp.capyreader" compileSdk = 34 @@ -16,8 +23,8 @@ android { applicationId = "com.jocmp.capyreader" minSdk = 30 targetSdk = 34 - versionCode = 1 - versionName = "1.0" + versionCode = 1000 + versionName = "v2024.06.1000" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" vectorDrawables { @@ -26,6 +33,13 @@ android { } signingConfigs { + create("release") { + storeFile = file("${project.rootDir}/release.keystore") + storePassword = secrets.getProperty("store_password") + keyAlias = secrets.getProperty("key_alias") + keyPassword = secrets.getProperty("key_password") + } + getByName("debug") { storeFile = file("${project.rootDir}/debug.keystore") } @@ -39,7 +53,7 @@ android { getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" ) - signingConfig = signingConfigs.getByName("debug") + signingConfig = signingConfigs.getByName("release") } } compileOptions { diff --git a/bumpver.toml b/bumpver.toml new file mode 100644 index 00000000..b3f611c8 --- /dev/null +++ b/bumpver.toml @@ -0,0 +1,19 @@ +[bumpver] +current_version = "v2024.06.1000" +version_pattern = "vYYYY.0M.BUILD" +commit_message = "Bump version {old_version} to {new_version}" +commit = true +tag = true +push = false + +[bumpver.file_patterns] +"README.md" = [ + "{version}", +] +"bumpver.toml" = [ + 'current_version = "{version}"', +] +"app/build.gradle.kts" = [ + 'versionName = "{version}"', + 'versionCode = BUILD' +] diff --git a/fastlane/Fastfile b/fastlane/Fastfile index b694ee7c..10df16da 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -1,23 +1,23 @@ default_platform(:android) platform :android do + desc 'Validate Play Store key' + lane :validate_key do + validate_play_store_json_key + end + desc "Runs all the tests" lane :test do gradle(task: "test") end - desc "Submit a new Beta Build to Crashlytics Beta" - lane :beta do - gradle(task: "clean assembleRelease") - crashlytics - - # sh "your_script.sh" - # You can also use other beta testing services here - end - desc "Deploy a new version to the Google Play" - lane :deploy do - gradle(task: "clean assembleRelease") + lane :production do + build_release upload_to_play_store end end + +def build_release + gradle(task: 'clean assembleRelease') +end diff --git a/fastlane/README.md b/fastlane/README.md index 7ec1207f..958fc450 100644 --- a/fastlane/README.md +++ b/fastlane/README.md @@ -15,26 +15,26 @@ For _fastlane_ installation instructions, see [Installing _fastlane_](https://do ## Android -### android test +### android validate_key ```sh -[bundle exec] fastlane android test +[bundle exec] fastlane android validate_key ``` -Runs all the tests +Validate Play Store key -### android beta +### android test ```sh -[bundle exec] fastlane android beta +[bundle exec] fastlane android test ``` -Submit a new Beta Build to Crashlytics Beta +Runs all the tests -### android deploy +### android production ```sh -[bundle exec] fastlane android deploy +[bundle exec] fastlane android production ``` Deploy a new version to the Google Play diff --git a/scripts/base64_encode b/scripts/base64_encode new file mode 100755 index 00000000..1a3fc792 --- /dev/null +++ b/scripts/base64_encode @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby + +# frozen_string_literal: true + +require 'base64' + +file_body = File.open(ARGV[0]).read + +puts Base64.strict_encode64(file_body) diff --git a/scripts/changelog b/scripts/changelog new file mode 100755 index 00000000..48d8ef13 --- /dev/null +++ b/scripts/changelog @@ -0,0 +1,20 @@ +#!/usr/bin/env ruby +require 'open3' +require 'fileutils' + +def fetch_config + result, _, _ = Open3.capture3("bumpver show -n --environ") + + result + .split(' ') + .map { |pair| pair.split('=', 2) } + .to_h +end + +build = fetch_config["BID"].to_i +next_build = build + 1 + +path = "fastlane/metadata/android/en-US/changelogs/#{next_build}.txt" +FileUtils.touch "./#{path}" + +puts "Added changelog for next build (#{next_build})\n./#{path}"