Skip to content

Commit

Permalink
CD setup (#21)
Browse files Browse the repository at this point in the history
* CI setup
* ci check for main branch
  • Loading branch information
psuzn authored Sep 22, 2023
1 parent 273be5e commit 075261d
Show file tree
Hide file tree
Showing 7 changed files with 205 additions and 10 deletions.
156 changes: 156 additions & 0 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
name: Create Release

on:
push:
tags:
- '*'
jobs:
lint_verify:
name: Lint and verify
runs-on: ubuntu-latest
steps:
- name: Exit if not on main branch
if: endsWith(github.ref, 'main') == false
run: exit -1

- uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: gradle

- name: Validate Gradle wrapper
uses: gradle/[email protected]

- name: Build Project with Gradle
uses: gradle/gradle-build-action@v2

- name: Lint
run: ./gradlew ktlintCheck

- name: Tests
run: ./gradlew :shared:testReleaseUnitTest

android_release:
name: Build and release android app
runs-on: ubuntu-latest
needs: lint_verify

steps:
- uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: gradle

- name: Build Project with Gradle
uses: gradle/gradle-build-action@v2

- name: Build Release AAB and apk
id: build_release
run: ./gradlew androidApp:assembleRelease androidApp:bundleRelease

- name: Sign AAB
id: sign_aab
uses: r0adkll/sign-android-release@v1
with:
releaseDirectory: androidApp/build/outputs/bundle/release
signingKeyBase64: ${{ secrets.SIGNING_KEY }}
alias: ${{ secrets.ALIAS }}
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}®
keyPassword: ${{ secrets.KEY_PASSWORD }}

- name: Upload to google play console
uses: r0adkll/upload-google-play@v1
id: upload_to_play_console
with:
serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT_JSON }}
packageName: me.sujanpoudel.playdeals
releaseFiles: ${{ steps.sign_aab.outputs.signedReleaseFile}}
inAppUpdatePriority: 5
whatsNewDirectory: CHANGELOG
releaseName: ${{ github.event.head_commit.message }}
status: draft

- name: Sign APK
id: sign_apk
uses: r0adkll/sign-android-release@v1
with:
releaseDirectory: androidApp/build/outputs/apk/release
signingKeyBase64: ${{ secrets.SIGNING_KEY }}
alias: ${{ secrets.ALIAS }}
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
keyPassword: ${{ secrets.KEY_PASSWORD }}

- uses: actions/upload-artifact@v3
with:
name: android-bundles
path: |
${{ steps.sign_aab.outputs.signedReleaseFile}}
${{ steps.sign_apk.outputs.signedReleaseFile}}
desktop_release:
name: Build desktop apps
strategy:
matrix:
os: [ 'ubuntu-latest', 'windows-latest','macos-latest' ]
needs: lint_verify
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: gradle

- name: Build Project with Gradle
uses: gradle/gradle-build-action@v2

- name: Bundle Package
id: bundle_package
run: |
./gradlew packageDistributionForCurrentOS
echo "package=$(ls desktopApp/build/compose/binaries/main*/*/deals-*-*.*)" >> $GITHUB_OUTPUT
shell: bash

- uses: actions/upload-artifact@v3
with:
name: ${{ matrix.os }}_bundle
path: ${{ steps.bundle_package.outputs.package }}

github_release:
needs: [ android_release,desktop_release ]
name: Create Release
runs-on: ubuntu-latest

steps:
- uses: actions/download-artifact@v3
with:
path: downloaded

- name: Collect artifacts
run: |
mkdir artifacts
TMP_APK=$(ls downloaded/android-bundles/apk/release/*.apk)
SIGNED_APK="${TMP_APK/-release-unsigned-signed/""}"
mv $TMP_APK $SIGNED_APK
mv downloaded/android-bundles/apk/release/* artifacts/
mv downloaded/android-bundles/bundle/release/* artifacts/
mv downloaded/**/*.* artifacts/
echo "ARTIFACTS=$(ls artifacts/*)" >> "$GITHUB_ENV"
- uses: softprops/action-gh-release@v1
with:
body_path: CHANGELOG/whatsnew-en-US
files: ${{ env.ARTIFACTS }}


11 changes: 7 additions & 4 deletions .github/workflows/ci.yaml → .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
name: play-deals-backend 1.0 CI
name: Lint and verify

on:
push:
pull_request:
workflow_dispatch:

jobs:
build:
lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: gradle

- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@ccb4328a959376b642e027874838f60f8e596de3
uses: gradle/wrapper-validation-action@v1.1.0

- name: Build Project with Gradle
uses: gradle/gradle-build-action@v2
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG/whatsnew-en-US
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
➤ Minor Bug Fixes
13 changes: 11 additions & 2 deletions androidApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,17 @@ kotlin {
android {
compileSdk = Artifact.ANDROID_COMPILE_SDK
namespace = Artifact.APP_ID

defaultConfig {
applicationId = "me.sujanpoudel.playdeals.app"
applicationId = Artifact.APP_ID

minSdk = Artifact.ANDROID_MIN_SDK
targetSdk = Artifact.ANDROID_TARGET_SDK

versionCode = Artifact.VERSION_CODE
versionName = Artifact.VERSION_NAME

setProperty("archivesBaseName", "play-deals-v$versionName-c$versionCode")
}

compileOptions {
Expand All @@ -35,7 +40,11 @@ android {

buildTypes {
getByName("release") {
isMinifyEnabled = false
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro",
)
}
}
}
23 changes: 23 additions & 0 deletions androidApp/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

-dontwarn org.slf4j.impl.StaticLoggerBinder
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/Artifacts.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
object Artifact {
const val APP_ID = "me.sujanpoudel.playdeals"
const val APP_NAME = "App Deals"
const val VERSION_CODE = 16
const val VERSION_NAME = "1.1.5"
const val VERSION_CODE = 17
const val VERSION_NAME = "1.1.6"
const val MAJOR_RELEASE = true

const val ANDROID_COMPILE_SDK = 34
Expand Down
7 changes: 5 additions & 2 deletions desktopApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ compose.desktop {
application {
mainClass = "MainKt"
nativeDistributions {
targetFormats(TargetFormat.Dmg, TargetFormat.Exe)
targetFormats(TargetFormat.Dmg, TargetFormat.Exe, TargetFormat.Deb)

packageVersion = Artifact.VERSION_NAME
packageName = Artifact.APP_NAME
packageName = "deals-${System.getProperty("os.arch")}"
copyright = "© 2023 Sujan Poudel. All rights reserved."
licenseFile.set(project.file("../LICENSE"))

Expand All @@ -41,9 +42,11 @@ compose.desktop {
iconFile.set(project.file("app_icon.icns"))
bundleID = Artifact.APP_ID
}

windows {
iconFile.set(project.file("app_icon.ico"))
}

linux {
iconFile.set(project.file("app_icon.png"))
}
Expand Down

0 comments on commit 075261d

Please sign in to comment.