Skip to content

Commit

Permalink
Merge pull request #96 from elimu-ai/model-2.0.62
Browse files Browse the repository at this point in the history
chore: Upgrade to model-2.0.62
  • Loading branch information
jo-elimu authored Nov 2, 2023
2 parents a814347 + 5a89e4a commit 016bf48
Show file tree
Hide file tree
Showing 7 changed files with 170 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Gradle CI
name: Gradle Build

on:
push:
Expand All @@ -10,7 +10,7 @@ jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/gradle-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Gradle Release

on:
workflow_dispatch:

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
cache: gradle

- run: git config user.name 'Nya Ξlimu'
- run: git config user.email '[email protected]'

- run: ./gradlew releaseClean
- run: ./gradlew releasePrepare -PbumpType=patch
- run: ./gradlew releasePerform
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,21 @@ Here is how to use the `utils` library in another Android app:
implementation 'com.github.elimu-ai:content-provider:<version>@aar'
}

See https://jitpack.io/#elimu-ai/content-provider/
See https://jitpack.io/#elimu-ai/content-provider/ for the latest version available.

### Usage Example

For an example of another Android app using the `utils` library, see the Vitabu app's Gradle configuration:

1. https://github.com/elimu-ai/vitabu/blob/master/build.gradle
1. https://github.com/elimu-ai/vitabu/blob/master/app/build.gradle
1. https://github.com/elimu-ai/vitabu/blob/main/build.gradle
1. https://github.com/elimu-ai/vitabu/blob/main/app/build.gradle

## Release 📦

See [.github/workflows/gradle-release.yml](.github/workflows/gradle-release.yml)

---

elimu.ai - Free personalized learning for every child on Earth 🌍🌏🌎
elimu.ai - Free open source learning software for out-of-school children ✨🚀

[Website 🌐](https://elimu.ai) &nbsp; [Wiki 📃](https://github.com/elimu-ai/wiki#readme) &nbsp; [Projects 👩🏽‍💻](https://github.com/elimu-ai/wiki/projects) &nbsp; [Milestones 🎯](https://github.com/elimu-ai/wiki/milestones) &nbsp; [Community 👋🏽](https://github.com/elimu-ai/wiki#open-source-community)
[Website 🌐](https://elimu.ai) &nbsp; [Wiki 📃](https://github.com/elimu-ai/wiki#readme) &nbsp; [Projects 👩🏽‍💻](https://github.com/orgs/elimu-ai/projects?query=is%3Aopen) &nbsp; [Milestones 🎯](https://github.com/elimu-ai/wiki/milestones) &nbsp; [Community 👋🏽](https://github.com/elimu-ai/wiki#open-source-community)
131 changes: 128 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
apply plugin: 'com.android.application'
apply plugin: 'org.ajoberstar.grgit'

android {
compileSdkVersion 32
compileSdk 33

defaultConfig {
applicationId "ai.elimu.content_provider"
minSdkVersion 24
targetSdkVersion 32
targetSdkVersion 33
versionCode 1002012
versionName "1.2.12-SNAPSHOT"
setProperty("archivesBaseName", "${applicationId}-${versionCode}")
Expand Down Expand Up @@ -40,7 +41,7 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation 'com.github.elimu-ai:model:model-2.0.53' // See https://jitpack.io/#elimu-ai/model
implementation 'com.github.elimu-ai:model:model-2.0.62' // See https://jitpack.io/#elimu-ai/model

implementation 'commons-io:commons-io:2.11.0'
implementation 'com.google.android.material:material:1.5.0'
Expand All @@ -67,3 +68,127 @@ dependencies {
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

task ensureCleanRepo {
doLast {
if (!grgit.repository.jgit.status().call().clean) {
throw new GradleException('Git status is not clean, please stash your changes!')
}
}
}

task releaseClean(dependsOn: ensureCleanRepo) {
doLast {
def clean = true
def applicationId = android.defaultConfig.applicationId

String headCommitMessage = grgit.head().shortMessage
while (headCommitMessage.contains("[gradle-release-task]")) {
clean = false
println "Found git commit: $headCommitMessage"
if (headCommitMessage.indexOf("$applicationId-") > -1) {
def tagName = headCommitMessage.split("$applicationId-")[1]
println "Removing the git tag: $tagName"
try {
grgit.tag.remove {
names = [tagName]
}
} catch (Exception e) {
println "Error while removing git tag:\n $e"
}
}
println "Resetting the git commit permanently!"
grgit.reset(commit: "HEAD~1", mode: "hard")
headCommitMessage = grgit.head().shortMessage

}
if (clean){
println "Repository is already clean"
}
println "Done!"
}
}

// Task parameters:
// bumpVersion -> if available will specify new versionName directly and ignores the `bumpType` parameter.
// bumpType[major|minor|patch] -> will specify how the version bumping occurs.
task releasePrepare(dependsOn: ensureCleanRepo) {
doLast {
def applicationId = android.defaultConfig.applicationId
def versionName = android.defaultConfig.versionName

if (versionName.indexOf("-") > -1) {
versionName = versionName.split("-")[0]
}

// Prepare the release commit with the specific tag.
String buildText = buildFile.getText()
buildText = buildText.replaceFirst(/versionName(\s+.*)/, "versionName '$versionName'")
buildFile.setText(buildText) //replace the build file's text
grgit.add(patterns: ['app/build.gradle'])
grgit.commit(message: "[gradle-release-task] prepare release $applicationId-$versionName")
try {
grgit.tag.add {
name = versionName
message = "Release of $versionName"
}
} catch (Exception e) {
throw new GradleException("Failed to tag the repo, error:\n $e")
}

// Set new version name from input parameters.
def newVersionName
if (project.properties.containsKey("bumpVersion")) {
newVersionName = project.properties["bumpVersion"]
println "Bumping the version directly (bumpVersion=$newVersionName)"
} else if (project.properties.containsKey("bumpType")) {
def (major, minor, patch) = versionName.tokenize('.')
switch (bumpType) {
case "major":
major = major.toInteger() + 1
minor = 0
patch = 0
break
case "minor":
minor = minor.toInteger() + 1
break
case "patch":
patch = patch.toInteger() + 1
break
}
newVersionName = "$major.$minor.$patch"
} else {
throw new GradleException('Either bumpType or bumpVersion parameters should be provided')
}

// Prepare for next development iteration.
def versionCode = android.defaultConfig.versionCode
def newVersionCode = versionCode + 1
println "Bumping versionName from $versionName to $newVersionName"
println "Bumping versionCode from $versionCode to $newVersionCode"
buildText = buildFile.getText()
buildText = buildText.replaceFirst(/versionName(\s+.*)/, "versionName '$newVersionName-SNAPSHOT'")
buildText = buildText.replaceFirst(/versionCode(\s+.*)/, "versionCode $newVersionCode")
buildFile.setText(buildText) //replace the build file's text
grgit.add(patterns: ['app/build.gradle'])
grgit.commit(message: "[gradle-release-task] prepare for next development iteration")
println "Done!"
}
}

task releasePerform(dependsOn: ensureCleanRepo) {
doLast {
boolean force = false
if (project.properties.containsKey("force")) {
force = project.properties["force"]
}
println "Pushing the newest commits to the remote repository (force: $force)"
try {
grgit.push(force: force, tags: true)
} catch (Exception e) {
throw new GradleException("Failed to push to the repo,\n" +
" you can try using -Pforce=true parameter to force the push, error: \n$e")
}
println "Done!"
}
}
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.3'
classpath 'org.ajoberstar.grgit:grgit-gradle:5.0.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
6 changes: 3 additions & 3 deletions utils/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ plugins {
}

android {
compileSdkVersion 32
compileSdk 33

defaultConfig {
minSdkVersion 24
targetSdkVersion 32
targetSdkVersion 33
versionCode 1002012
versionName "1.2.12-SNAPSHOT"
setProperty("archivesBaseName", "utils-${versionName}")
Expand All @@ -26,7 +26,7 @@ android {
}

dependencies {
implementation 'com.github.elimu-ai:model:model-2.0.53' // See https://jitpack.io/#elimu-ai/model
implementation 'com.github.elimu-ai:model:model-2.0.62' // See https://jitpack.io/#elimu-ai/model
implementation 'com.github.elimu-ai:analytics:3.1.11@aar' // See https://jitpack.io/#elimu-ai/analytics
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ public static List<WordGson> getAvailableWordGsons(Context context, String conte
return wordGsons;
}

/**
* This method is only meant to be used for testing purposes during development.
*/
public static List<WordGson> getAllWordGsons(Context context, String contentProviderApplicationId) {
Log.i(ContentProviderUtil.class.getName(), "getAllWordGsons");

Expand Down

0 comments on commit 016bf48

Please sign in to comment.