Skip to content

Commit

Permalink
ci: add initial github workflow
Browse files Browse the repository at this point in the history
Signed-off-by: jnelle <[email protected]>

ci: add missing distribution

Signed-off-by: jnelle <[email protected]>

Update android.yml

Update android.yml

Update android.yml

Update android.yml

chore: add signingconfig

Signed-off-by: jnelle <[email protected]>

ci: change path to apk

Signed-off-by: jnelle <[email protected]>

Update android.yml

Update android.yml

Update android.yml

Update android.yml

ci: use github token

Signed-off-by: jnelle <[email protected]>
  • Loading branch information
jnelle committed Jun 22, 2024
1 parent 5b22f27 commit 55b89d7
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 4 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: CI/CD

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: set up JDK 21
uses: actions/setup-java@v4
with:
java-version: 21
distribution: 'zulu'
- uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: ${{ runner.os }}-gradle-
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Retrieve the keystore and decode it to a file
env:
ANDROID_RELEASE_KEYSTORE_FILE: ${{ secrets.ANDROID_RELEASE_KEYSTORE_FILE }}
run: |
mkdir release
echo $ANDROID_RELEASE_KEYSTORE_FILE | base64 --decode > release/release.keystore
- name: Write local.properties
env:
ANDROID_RELEASE_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_RELEASE_KEYSTORE_PASSWORD }}
ANDROID_RELEASE_KEY_ALIAS: ${{ secrets.ANDROID_RELEASE_KEY_ALIAS }}
ANDROID_RELEASE_KEY_PASSWORD: ${{ secrets.ANDROID_RELEASE_KEY_PASSWORD }}
run: |
echo androidReleaseStoreFile=/release/release.keystore >> local.properties
echo androidReleaseStorePassword=$ANDROID_RELEASE_KEYSTORE_PASSWORD >> local.properties
echo androidReleaseKeyAlias=$ANDROID_RELEASE_KEY_ALIAS >> local.properties
echo androidReleaseKeyPassword=$ANDROID_RELEASE_KEY_PASSWORD >> local.properties
- name: Build release apk
run: ./gradlew :composeApp:assembleRelease
- name: Get Next Version
id: semver
uses: ietf-tools/semver-action@v1
with:
token: ${{ github.token }}
branch: master
patchList: "ci", "refactor", "fix", "style", "chore"
- name: Create Release
uses: ncipollo/[email protected]
with:
allowUpdates: true
draft: false
makeLatest: true
name: ${{ steps.semver.outputs.next }}
body: Changelog Contents
token: ${{ github.token }}

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: release.apk
path: composeApp/build/outputs/apk/release/composeApp-release.apk

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ captures
**/xcshareddata/WorkspaceSettings.xcsettings
.fleet/
.kotlin/
composeApp/release/
composeApp/release/
release/
25 changes: 22 additions & 3 deletions composeApp/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
plugins {
import java.util.Properties

plugins {
alias(libs.plugins.kotlinMultiplatform)
alias(libs.plugins.androidApplication)
alias(libs.plugins.jetbrainsCompose)
Expand Down Expand Up @@ -66,7 +68,13 @@ kotlin {
}
}
}

val localProperties = Properties()
val localPropertiesFile = rootProject.file("local.properties")
if (localPropertiesFile.exists()) {
localPropertiesFile.inputStream().use { input ->
localProperties.load(input)
}
}
android {
namespace = "com.mgtv"
compileSdk = libs.versions.android.compileSdk.get().toInt()
Expand All @@ -87,11 +95,20 @@ android {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}

signingConfigs {
create("release") {
storeFile = file("$rootDir/release/release.keystore")
storePassword = localProperties.getProperty("androidReleaseStorePassword")
keyAlias = "mgtv"
keyPassword = localProperties.getProperty("androidReleaseKeyPassword")
}
}

buildTypes {
getByName("release") {
isMinifyEnabled = true
isShrinkResources = true

proguardFiles(
// Includes the default ProGuard rules files that are packaged with
// the Android Gradle plugin. To learn more, go to the section about
Expand All @@ -100,8 +117,10 @@ android {
// Includes a local, custom Proguard rules file
"proguard-rules.pro",
)
signingConfig = signingConfigs.getByName("release")
}
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
Expand Down

0 comments on commit 55b89d7

Please sign in to comment.