Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/Android-CI-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
name: Publish release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- uses: actions/checkout@v6
with:
fetch-depth: 0
submodules: true
- name: Install JDK ${{ matrix.java_version }}
uses: actions/setup-java@v5
with:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/Android-CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ jobs:
run: |
sudo apt-get update && sudo apt-get install -y exiftool imagemagick xdg-utils libimage-exiftool-perl zsh jq xorg
- uses: actions/checkout@v6
with:
fetch-depth: 0
submodules: true
- name: set up JDK
uses: actions/setup-java@v5
with:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/update-gradle-wrapper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ jobs:

steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
submodules: true
- name: Install JDK
uses: actions/setup-java@v5
with:
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "buildSrc"]
path = buildSrc
url = git@github.com:hannesa2/KotlinBuildSource.git
67 changes: 41 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,35 +28,50 @@ This library provides an easy way to update app with provided apk in release.
)
```

3. And you need repository info eg in `build.config`

```groovy
3. And you need repository info eg in `build.gradle.kts`

In kts you can use submodule buildSrc

```kotlin
import info.git.versionHelper.getGitCommitCount
import info.git.versionHelper.getGitOriginRemote

android {
defaultConfig {
...
versionCode getGitCommitCount()

buildConfigField "String", 'GIT_REPOSITORY', "\"" + getGitRepository() + "\""
}

static def getGitCommitCount() {
def process = "git rev-list HEAD --count".execute()
return process.text.toInteger()
versionCode = getGitCommitCount()
buildConfigField("String", "GIT_REPOSITORY", "\"" + getGitOriginRemote() + "\"")
}

static def getGitOriginRemote() {
def process = "git remote -v".execute()
def values = process.text.toString().trim().split("\\r\\n|\\n|\\r")

def found = values.find { it.startsWith("origin") && it.endsWith("(push)") }
return found.replace("origin", "").replace("(push)", "").replace(".git", "").trim()
}

static def getGitRepository() {
def token = getGitOriginRemote().split("/")
return token[4]
}
```
eg groovy in `build.gradle`
```groovy
android {
defaultConfig {
...
versionCode getGitCommitCount()

buildConfigField "String", 'GIT_REPOSITORY', "\"" + getGitRepository() + "\""
}
```
}

static def getGitCommitCount() {
def process = "git rev-list HEAD --count".execute()
return process.text.toInteger()
}

static def getGitOriginRemote() {
def process = "git remote -v".execute()
def values = process.text.toString().trim().split("\\r\\n|\\n|\\r")

def found = values.find { it.startsWith("origin") && it.endsWith("(push)") }
return found.replace("origin", "").replace("(push)", "").replace(".git", "").trim()
}

static def getGitRepository() {
def token = getGitOriginRemote().split("/")
return token[4]
}
```
## Include the library

The easiest way to add `githubAppUpdate` to your project is via Gradle. Just add the following lines to your `build.gradle`:
Expand All @@ -83,7 +98,7 @@ You can specify now an optional personal access token for github. Then it works

## License

Copyright (C) 2025 hannesa2
Copyright (C) 2026 hannesa2

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
62 changes: 0 additions & 62 deletions app/build.gradle

This file was deleted.

58 changes: 58 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import info.git.versionHelper.getGitCommitCount
import info.git.versionHelper.getGitOriginRemote
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
id("com.android.application")
id("kotlin-android")
}

android {
namespace = "info.hannes.github.sample"
compileSdk = 36
defaultConfig {
versionCode = getGitCommitCount()
versionName = "1.0"

minSdk = 23

buildConfigField("String", "GIT_REPOSITORY", "\"" + getGitOriginRemote() + "\"")

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments.putAll(
mapOf(
"useTestStorageService" to "true",
),
)
}
packaging {
resources {
pickFirsts += setOf("META-INF/atomicfu.kotlin_module")
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlin {
compilerOptions {
jvmTarget = JvmTarget.JVM_17
}
}

buildFeatures {
viewBinding = true
}
}

dependencies {
implementation(project(":githubAppUpdate"))
implementation("androidx.legacy:legacy-support-v4:1.0.0")
implementation("androidx.appcompat:appcompat:1.7.1")
implementation("com.google.android.material:material:1.13.0")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.1.0")

androidTestImplementation("androidx.test.ext:junit-ktx:1.2.1")
androidTestUtil("androidx.test.services:test-services:1.6.0")
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1")
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package info.hannes.github.sample
import android.graphics.Bitmap
import androidx.test.core.graphics.writeToTestStorage
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.Espresso.pressBack
import androidx.test.espresso.action.ViewActions.captureToBitmap
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.assertion.ViewAssertions.matches
Expand All @@ -27,6 +28,9 @@ class SmokeTest {

@Test
fun smokeTestSimplyStart() {
// Dismiss the dialog by pressing back
pressBack()

onView(isRoot())
.perform(captureToBitmap { bitmap: Bitmap -> bitmap.writeToTestStorage("${javaClass.simpleName}_${nameRule.methodName}-R") })

Expand Down
7 changes: 3 additions & 4 deletions build.gradle → build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import org.gradle.internal.jvm.Jvm

buildscript {
ext.kotlin_version = "2.3.10"
repositories {
google()
mavenCentral()
}

dependencies {
classpath "com.android.tools.build:gradle:8.13.0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath("com.android.tools.build:gradle:8.13.0")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:2.1.0")
}
}

println "Gradle uses Java ${Jvm.current()}"
println("Gradle uses Java ${Jvm.current()}")

allprojects {
repositories {
Expand Down
1 change: 1 addition & 0 deletions buildSrc
Submodule buildSrc added at abb98b
51 changes: 0 additions & 51 deletions githubAppUpdate/build.gradle

This file was deleted.

Loading
Loading