Skip to content

Commit bb3a27d

Browse files
committed
Add play store build automatization
1 parent 5ea6f56 commit bb3a27d

7 files changed

Lines changed: 99 additions & 3 deletions

File tree

.github/workflows/android.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,60 @@ jobs:
296296
name: appimage-package
297297
path: LinuxCommandLibrary-*.AppImage
298298

299+
play-store:
300+
name: Upload AAB to Play Store
301+
runs-on: ubuntu-latest
302+
steps:
303+
- name: Checkout
304+
uses: actions/checkout@v4
305+
with:
306+
fetch-depth: 0
307+
- name: Setup JDK
308+
uses: actions/setup-java@v4
309+
with:
310+
distribution: temurin
311+
java-version: "17"
312+
- name: Set execution flag for gradlew
313+
run: chmod +x gradlew
314+
- name: Setup Android SDK
315+
uses: android-actions/setup-android@v3
316+
- name: Decode keystore
317+
run: echo "${{ secrets.KEYSTORE_B64 }}" | base64 --decode > /tmp/keystore.jks
318+
- name: Decode service account key
319+
run: echo "${{ secrets.SERVICE_ACCOUNT_JSON }}" | base64 --decode > fastlane/play-store-key.json
320+
- name: Extract changelog for Play Store
321+
run: |
322+
VERSION="${GITHUB_REF_NAME#v}"
323+
VERSION_CODE=$(grep "androidVersionCode" gradle/libs.versions.toml | head -1 | sed 's/.*= *"\([0-9]*\)".*/\1/')
324+
CHANGELOG_DIR="fastlane/metadata/android/en-US/changelogs"
325+
mkdir -p "$CHANGELOG_DIR"
326+
if [ -f CHANGELOG.md ]; then
327+
sed -n "/^## v${VERSION}/,/^## v/{ /^## v${VERSION}/d; /^## v/d; p; }" CHANGELOG.md > "$CHANGELOG_DIR/${VERSION_CODE}.txt"
328+
fi
329+
if [ ! -s "$CHANGELOG_DIR/${VERSION_CODE}.txt" ]; then
330+
PREVIOUS_TAG=$(git tag --sort=-creatordate | grep -v "^${GITHUB_REF_NAME}$" | head -n1)
331+
if [ -z "$PREVIOUS_TAG" ]; then
332+
git log --pretty=format:"- %s" "${GITHUB_REF_NAME}" > "$CHANGELOG_DIR/${VERSION_CODE}.txt"
333+
else
334+
git log --pretty=format:"- %s" "${PREVIOUS_TAG}..${GITHUB_REF_NAME}" --no-merges > "$CHANGELOG_DIR/${VERSION_CODE}.txt"
335+
fi
336+
fi
337+
# Play Store changelog limit is 500 characters
338+
truncate -s '<500' "$CHANGELOG_DIR/${VERSION_CODE}.txt" 2>/dev/null || true
339+
- name: Build signed AAB
340+
run: ./gradlew bundleRelease --stacktrace
341+
env:
342+
KEYSTORE_FILE: /tmp/keystore.jks
343+
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
344+
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
345+
- name: Setup Ruby
346+
uses: ruby/setup-ruby@v1
347+
with:
348+
ruby-version: '3.2'
349+
bundler-cache: true
350+
- name: Deploy to Play Store
351+
run: bundle exec fastlane android deploy
352+
299353
release:
300354
name: Release All Platforms
301355
needs: [apk, cli-linux, cli-macos, cli-windows, dmg, msi, deb, rpm, appimage]

Gemfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
source "https://rubygems.org"
2+
3+
gem "fastlane"

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ Native CLI and GUI binaries for Linux, macOS, and Windows are available in [Rele
1515

1616
GUI:
1717

18-
```brew install --cask simonschubert/tap/linux-command-library```
18+
```
19+
brew install --cask simonschubert/tap/linux-command-library
20+
```
1921

2022
CLI:
2123

android/build.gradle.kts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,29 @@ android {
3838
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
3939
}
4040

41+
signingConfigs {
42+
create("release") {
43+
val ksFile = System.getenv("KEYSTORE_FILE")
44+
if (ksFile != null) {
45+
storeFile = file(ksFile)
46+
storePassword = System.getenv("KEYSTORE_PASSWORD")
47+
keyAlias = System.getenv("KEY_ALIAS")
48+
keyPassword = System.getenv("KEYSTORE_PASSWORD")
49+
}
50+
}
51+
}
4152
buildTypes {
4253
getByName("release") {
4354
isMinifyEnabled = true
4455
proguardFiles(
4556
getDefaultProguardFile("proguard-android-optimize.txt"),
4657
)
58+
signingConfig =
59+
if (System.getenv("KEYSTORE_FILE") != null) {
60+
signingConfigs.getByName("release")
61+
} else {
62+
signingConfigs.getByName("debug")
63+
}
4764
}
4865
getByName("debug") {
4966
isMinifyEnabled = false

fastlane/Appfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
package_name("com.inspiredandroid.linuxcommandbibliotheca")
2+
json_key_file("fastlane/play-store-key.json")

fastlane/Fastfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
default_platform(:android)
2+
3+
platform :android do
4+
desc "Deploy AAB to Play Store production"
5+
lane :deploy do
6+
upload_to_play_store(
7+
track: 'production',
8+
aab: 'android/build/outputs/bundle/release/android-release.aab',
9+
skip_upload_metadata: true,
10+
skip_upload_images: true,
11+
skip_upload_screenshots: true,
12+
)
13+
end
14+
end

websiteBuilder/src/main/kotlin/com/linuxcommandlibrary/desktop/MarkdownBuilder.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,15 @@ class MarkdownBuilder {
4444
stream.appendLine()
4545
stream.appendLine("GUI:")
4646
stream.appendLine()
47-
stream.appendLine("```brew install --cask simonschubert/tap/linux-command-library```")
47+
stream.appendLine("```")
48+
stream.appendLine("brew install --cask simonschubert/tap/linux-command-library")
49+
stream.appendLine("```")
4850
stream.appendLine()
4951
stream.appendLine("CLI:")
5052
stream.appendLine()
51-
stream.appendLine("```brew install simonschubert/tap/linux-command-library-cli```")
53+
stream.appendLine("```")
54+
stream.appendLine("brew install simonschubert/tap/linux-command-library-cli")
55+
stream.appendLine("```")
5256
stream.appendLine()
5357
stream.appendLine("### Android screenshots")
5458
stream.appendLine()

0 commit comments

Comments
 (0)