Skip to content

Commit 05ca96e

Browse files
Merge pull request #1 from ovitrif/master
feat: github packages android distribution
2 parents 01aeeeb + 33386c2 commit 05ca96e

File tree

19 files changed

+643
-6
lines changed

19 files changed

+643
-6
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created
2+
# For more info see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle
3+
4+
name: Gradle Publish
5+
6+
on:
7+
release:
8+
types: [created]
9+
workflow_dispatch:
10+
inputs:
11+
version:
12+
description: 'Version to publish (e.g. v0.1.0)'
13+
required: true
14+
15+
jobs:
16+
publish:
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: read
20+
packages: write
21+
defaults:
22+
run:
23+
working-directory: bindings/android
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
28+
- name: Set up JDK
29+
uses: actions/setup-java@v4
30+
with:
31+
java-version: '17'
32+
distribution: 'temurin'
33+
server-id: github
34+
settings-path: ${{ github.workspace }}
35+
36+
- name: Extract version
37+
id: version
38+
shell: bash
39+
run: |
40+
VERSION="${{ inputs.version }}"
41+
if [[ -z "$VERSION" ]]; then
42+
VERSION="$GITHUB_REF_NAME"
43+
fi
44+
echo "version=${VERSION#v}" >> $GITHUB_OUTPUT
45+
46+
- name: Build
47+
run: ./gradlew assembleRelease -Pversion=${{ steps.version.outputs.version }}
48+
49+
- name: Publish
50+
run: ./gradlew publish -Pversion=${{ steps.version.outputs.version }}
51+
env:
52+
GITHUB_ACTOR: ${{ github.actor }}
53+
GITHUB_TOKEN: ${{ secrets.ORG_PACKAGES_TOKEN }}
54+
GITHUB_REPO: ${{ github.repository }}

bindings/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.gradle
2+
build
3+
local.properties

bindings/android/README.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# VSS Rust Client Android
2+
3+
Android library exposing Kotlin bindings for the VSS Rust client FFI.
4+
5+
## Installation
6+
7+
### GitHub Packages
8+
9+
1) Setup your GitHub credentials
10+
11+
Create a GitHub PAT (Personal Access Token):
12+
- Go to GitHub → Settings → Developer settings → Personal access tokens → Tokens (classic)
13+
- Generate new token with scopes: `read:packages` (and `repo` if package/repo is private)
14+
- Copy the token once and use it in the next steps:
15+
16+
Set env vars:
17+
```sh
18+
export GITHUB_ACTOR="your_github_username"
19+
export GITHUB_TOKEN="your_pat_with_read:packages"
20+
```
21+
22+
Or add to `~/.gradle/gradle.properties`:
23+
```properties
24+
gpr.user=<your_github_username>
25+
gpr.key=<your_pat_with_read:packages>
26+
```
27+
28+
#### 2. Add the GitHub Packages repository
29+
30+
```kotlin
31+
// settings.gradle.kts
32+
dependencyResolutionManagement {
33+
repositories {
34+
google()
35+
mavenCentral()
36+
maven {
37+
url = uri("https://maven.pkg.github.com/synonymdev/vss-rust-client-ffi")
38+
credentials {
39+
username = System.getenv("GITHUB_ACTOR") ?: providers.gradleProperty("gpr.user").orNull
40+
password = System.getenv("GITHUB_TOKEN") ?: providers.gradleProperty("gpr.key").orNull
41+
}
42+
}
43+
}
44+
}
45+
```
46+
47+
#### 3. Declare the dependency
48+
49+
```kotlin
50+
// app/build.gradle.kts
51+
dependencies {
52+
implementation("com.synonym:vss-client-android:<VERSION>")
53+
// example:
54+
// implementation("com.synonym:vss-client-android:0.1.0")
55+
}
56+
```
57+
### Maven Local (development)
58+
59+
```kotlin
60+
// settings.gradle.kts
61+
dependencyResolutionManagement {
62+
repositories {
63+
mavenLocal()
64+
// others
65+
}
66+
}
67+
68+
// build.gradle.kts
69+
dependencies {
70+
implementation("com.synonym:vss-rust-client-ffi:<LOCAL_VERSION>")
71+
}
72+
```
73+
74+
---
75+
76+
## Publishing
77+
78+
**⚠️ Reminder:** Versions are immutable, bump for each publish.
79+
80+
### GitHub Actions
81+
82+
Create a GitHub Release with a new tag like `v0.1.0`. The workflow `gradle-publish.yml` will publish that version.
83+
84+
Or trigger the "Gradle Publish" workflow manually.
85+
86+
### Terminal
87+
88+
```sh
89+
cd bindings/android
90+
./gradlew publish -Pversion=0.1.0
91+
```

bindings/android/build.gradle.kts

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
import java.util.Properties
2+
3+
plugins {
4+
id("com.android.library") version "8.5.2"
5+
id("org.jetbrains.kotlin.android") version "1.9.24"
6+
id("maven-publish")
7+
id("signing")
8+
}
9+
10+
group = "com.synonym"
11+
version = providers.gradleProperty("version").orNull ?: "0.0.0"
12+
13+
android {
14+
namespace = "com.synonym.vssclient"
15+
compileSdk = 34
16+
17+
defaultConfig {
18+
minSdk = 21
19+
consumerProguardFiles("consumer-rules.pro")
20+
}
21+
buildTypes {
22+
release {
23+
isMinifyEnabled = false
24+
proguardFiles(file("proguard-android-optimize.txt"), file("proguard-rules.pro"))
25+
}
26+
}
27+
compileOptions {
28+
sourceCompatibility = JavaVersion.VERSION_11
29+
targetCompatibility = JavaVersion.VERSION_11
30+
}
31+
kotlinOptions {
32+
jvmTarget = "11"
33+
}
34+
publishing {
35+
singleVariant("release") {
36+
withSourcesJar()
37+
withJavadocJar()
38+
}
39+
}
40+
}
41+
42+
dependencies {
43+
implementation("net.java.dev.jna:jna:5.17.0@aar")
44+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1")
45+
}
46+
47+
afterEvaluate {
48+
publishing {
49+
publications {
50+
create<MavenPublication>("maven") {
51+
val mavenArtifactId = "vss-client-android"
52+
groupId = project.group.toString()
53+
artifactId = mavenArtifactId
54+
version = project.version.toString()
55+
56+
from(components["release"])
57+
pom {
58+
name.set(mavenArtifactId)
59+
description.set("VSS Rust Client Android bindings.")
60+
url.set("https://github.com/synonymdev/vss-rust-client-ffi")
61+
licenses {
62+
license {
63+
name.set("MIT")
64+
url.set("https://github.com/synonymdev/vss-rust-client-ffi/blob/master/LICENSE")
65+
}
66+
}
67+
developers {
68+
developer {
69+
id.set("synonymdev")
70+
name.set("Synonym")
71+
email.set("noreply@synonym.to")
72+
}
73+
}
74+
}
75+
}
76+
}
77+
repositories {
78+
maven {
79+
name = "GitHubPackages"
80+
val repo = System.getenv("GITHUB_REPO")
81+
?: providers.gradleProperty("gpr.repo").orNull
82+
?: "synonymdev/vss-rust-client-ffi"
83+
url = uri("https://maven.pkg.github.com/$repo")
84+
credentials {
85+
username = System.getenv("GITHUB_ACTOR") ?: providers.gradleProperty("gpr.user").orNull
86+
password = System.getenv("GITHUB_TOKEN") ?: providers.gradleProperty("gpr.key").orNull
87+
}
88+
}
89+
}
90+
}
91+
}

bindings/android/gradle.properties

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
org.gradle.jvmargs=-Xmx2g -Dfile.encoding=UTF-8
2+
android.useAndroidX=true
3+
android.nonTransitiveRClass=true
4+
kotlin.code.style=official
5+
# project settings:
6+
version=0.1.0
42.6 KB
Binary file not shown.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
6+
zipStoreBase=GRADLE_USER_HOME
7+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)