Skip to content
Merged
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
68 changes: 68 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,71 @@ jobs:
path: |
**/build/outputs/aar/*.aar
**/build/libs/*.jar
publish:
name: Publish Release
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')

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

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'

- name: Make gradlew executable
run: chmod +x ./gradlew

- name: Extract version from Git tag
id: version
run: |
TAG=${GITHUB_REF#refs/tags/}
VERSION_NAME=${TAG#v}
echo "VERSION_NAME=$VERSION_NAME" >> $GITHUB_ENV

- name: Detect release type
id: release_type
run: |
if [[ "${GITHUB_REF}" == *alpha* ]]; then
echo "release_stage=alpha" >> $GITHUB_OUTPUT
elif [[ "${GITHUB_REF}" == *beta* ]]; then
echo "release_stage=beta" >> $GITHUB_OUTPUT
else
echo "release_stage=stable" >> $GITHUB_OUTPUT
fi
- name: Restore gradle.properties
env:
GRADLE_PROPERTIES: ${{ secrets.GRADLE_PROPERTIES }}
shell: bash
run: |
mkdir -p ~/.gradle/
echo "GRADLE_USER_HOME=${HOME}/.gradle" >> $GITHUB_ENV
echo "${GRADLE_PROPERTIES}" > ~/.gradle/gradle.properties
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}

- name: Publish to Maven Central
run: ./gradlew formz:publishAllPublicationsToMavenCentral --no-configuration-cache -PVERSION_NAME=${{ env.VERSION_NAME }}

- name: Upload GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref_name }}
name: Release ${{ github.ref_name }}
body: |
🚀 **Release:** `${{ github.ref_name }}`
🏷 **Type:** `${{ steps.release_type.outputs.release_stage }}`

This release was automatically published from CI.
draft: false
prerelease: ${{ steps.release_type.outputs.release_stage != 'stable' }}
files: |
**/build/outputs/aar/*.aar
**/build/libs/*.jar
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ plugins {
alias(libs.plugins.compose.compiler) apply false
alias(libs.plugins.arturbosch.detekt) apply false
alias(libs.plugins.spotless) apply false
alias(libs.plugins.maven.publish) apply false
}

val detektVersion = libs.versions.detekt.get()
Expand Down
51 changes: 32 additions & 19 deletions formz/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget
plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.jetbrains.kotlin.android)
id("maven-publish")
alias(libs.plugins.maven.publish)
alias(libs.plugins.signing)
}

val versionName = project.findProperty("VERSION_NAME") as String? ?: "0.0.6-alpha"
android {
namespace = "com.nareshchocha.formz"
compileSdk =
Expand Down Expand Up @@ -39,32 +40,44 @@ android {
jvmTarget.set(JvmTarget.JVM_21)
}
}
publishing {
singleVariant("release") {
withSourcesJar()
withJavadocJar()
}
}
}

dependencies {

testImplementation(libs.junit)
}

publishing {
publications {
create<MavenPublication>("release") {
groupId = "com.github.ChochaNaresh"
artifactId = "formz"
version = "0.0.5"
val automaticRelease: Boolean = true
mavenPublishing {
publishToMavenCentral(automaticRelease)
signAllPublications()
coordinates("io.github.chochanaresh", "formz", versionName)

afterEvaluate {
from(components["release"])
/* from {
components.release
}*/
pom {
name.set("formz")
description.set(
"Formz is a lightweight validation framework for Android forms written in Kotlin. It provides a simple, yet powerful way to define, validate, and manage form inputs in your Android applications. The library is designed with immutability and performance in mind, ensuring that expensive validation logic is computed only once per input."
)
inceptionYear.set("2025")
url.set("https://github.com/ChochaNaresh/Formz")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set("ChochaNaresh")
name.set("Naresh Chocha")
url.set("https://github.com/ChochaNaresh")
}
}
scm {
url.set("https://github.com/ChochaNaresh/Formz")
connection.set("scm:git:git://github.com/ChochaNaresh/Formz.git")
developerConnection.set("scm:git:ssh://git@github.com/ChochaNaresh/Formz.git")
}
}
}
5 changes: 5 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
agp = "8.11.0"
kotlin = "2.2.0"
detekt = "1.23.8"
mavenPublish = "0.33.0"
compileSdk = "36"
targetSdk = "36"
minSdk = "21"
Expand Down Expand Up @@ -55,4 +56,8 @@ compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "
# code style review
arturbosch-detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
spotless = { id = "com.diffplug.spotless", version = "7.0.4" }
# maven publish
maven-publish = { id = "com.vanniktech.maven.publish", version.ref = "mavenPublish" }
# signing
signing = { id = "signing" }

Binary file added secring.gpg
Binary file not shown.