Skip to content

Commit

Permalink
Add build on CI workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
mr3y-the-programmer committed Feb 5, 2024
1 parent 716d395 commit 10b731a
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 4 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Build and run local tests

on:
push:
branches:
- main
tags-ignore:
- 'v*'
paths-ignore:
- '**.md'
- '**.txt'
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true

env:
API_KEY: ${{ secrets.API_KEY }}
API_SECRET: ${{ secrets.API_SECRET }}

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v2

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

- name: Setup Gradle
uses: gradle/gradle-build-action@v3

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build debug
run: ./gradlew assembleDebug --stacktrace

- name: Run local tests
run: ./gradlew testDebug --stacktrace

- name: Apply ktlint formatting to (.kt/s) files.
run: ./gradlew ktlintFormat --stacktrace

- name: Commit and push changes (if any).
if: ${{ github.ref == 'refs/heads/main' }}
uses: EndBug/add-and-commit@v9
with:
author_name: GitHub Actions
author_email: [email protected]
message: Apply style formatting
push: true

- name: Upload build outputs (APKs)
uses: actions/upload-artifact@v4
with:
name: build-outputs
path: |
**/build/outputs/*
- name: Upload build reports
if: always()
uses: actions/upload-artifact@v4
with:
name: build-reports
path: ./**/build/reports
16 changes: 12 additions & 4 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@ android {
useSupportLibrary = true
}

val properties = Properties()
properties.load(FileInputStream(rootProject.file("local.properties")))
buildConfigField("String", "API_KEY", "\"${properties.getProperty("API_KEY")}\"")
buildConfigField("String", "API_SECRET", "\"${properties.getProperty("API_SECRET")}\"")
buildConfigField("String", "API_KEY", "\"${getValueOfKey("API_KEY")}\"")
buildConfigField("String", "API_SECRET", "\"${getValueOfKey("API_SECRET")}\"")
}

buildTypes {
Expand Down Expand Up @@ -125,6 +123,16 @@ ksp {
arg("lyricist.packageName", "com.mr3y.podcaster")
}

fun getValueOfKey(key: String) {
if (System.getenv("CI").toBoolean()) {
System.getenv(key)
} else {
val properties = Properties()
properties.load(FileInputStream(rootProject.file("local.properties")))
properties.getProperty(key)
}
}

dependencies {
implementation(libs.core.ktx)
implementation(libs.splashscreen)
Expand Down

0 comments on commit 10b731a

Please sign in to comment.