Skip to content

Commit

Permalink
Add config to deploy to Google Play (#114)
Browse files Browse the repository at this point in the history
* Add config to deploy to Google Play

* Add workflow to create release
  • Loading branch information
jocmp committed Jun 24, 2024
1 parent f7c17e3 commit 19b802a
Show file tree
Hide file tree
Showing 11 changed files with 178 additions and 23 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
- name: Create Release
id: create_release
uses: actions/[email protected]
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
38 changes: 38 additions & 0 deletions .github/workflows/deploy-production.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
with:
ssh-key: ${{ secrets.RELEASE_SSH_KEY }}
- name: Set up Ruby
uses: ruby/[email protected]
- name: Set up Java
uses: actions/[email protected]
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 "[email protected]"
- 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
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
21 changes: 20 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Capy Reader

[![CalVer v2024.06.1000][img_version]][url_version]

<img src="./site/capy.png" width="100px">

_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
20 changes: 17 additions & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import com.android.build.gradle.internal.tasks.factory.dependsOn
import java.util.Properties

plugins {
id("com.android.application")
Expand All @@ -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
Expand All @@ -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 {
Expand All @@ -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")
}
Expand All @@ -39,7 +53,7 @@ android {
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
signingConfig = signingConfigs.getByName("debug")
signingConfig = signingConfigs.getByName("release")
}
}
compileOptions {
Expand Down
19 changes: 19 additions & 0 deletions bumpver.toml
Original file line number Diff line number Diff line change
@@ -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'
]
22 changes: 11 additions & 11 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
@@ -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
16 changes: 8 additions & 8 deletions fastlane/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions scripts/base64_encode
Original file line number Diff line number Diff line change
@@ -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)
20 changes: 20 additions & 0 deletions scripts/changelog
Original file line number Diff line number Diff line change
@@ -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}"

0 comments on commit 19b802a

Please sign in to comment.