Skip to content

Commit 7b55467

Browse files
add github packages publishing
1 parent 8312024 commit 7b55467

4 files changed

Lines changed: 114 additions & 4 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Publish to GitHub Packages
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
publish:
8+
runs-on: ubuntu-latest
9+
permissions:
10+
contents: read
11+
packages: write
12+
13+
steps:
14+
- name: Check out repo
15+
uses: actions/checkout@v4
16+
17+
- name: Set up JDK 21
18+
uses: actions/setup-java@v4
19+
with:
20+
java-version: "21"
21+
distribution: "temurin"
22+
cache: gradle
23+
24+
- name: Setup Gradle
25+
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0
26+
27+
- name: Publish to GitHub Packages
28+
run: ./gradlew publishAllPublicationsToGitHubPackagesRepository --no-configuration-cache -PsignPublications=false
29+
env:
30+
GITHUB_ACTOR: ${{ github.actor }}
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
GITHUB_REPOSITORY: ${{ github.repository }}

README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
> **NOTICE: Temporary Fork — Not Maintained**
2+
> This is a temporary fork of [valhalla-openapi-models-kotlin](https://github.com/Rallista/valhalla-openapi-models-kotlin).
3+
> It is published to GitHub Packages for internal use only and is **not actively maintained**.
4+
> For production use, please use the upstream library from Maven Central.
5+
16
# Valhalla Mobile OpenAPI Kotlin
27

38
Kotlin serializable [Valhalla](https://github.com/valhalla/valhalla) API and configuration models.
@@ -38,6 +43,49 @@ implementation 'io.github.rallista:valhalla-models-config:0.0.8'
3843
implementation 'io.github.rallista:valhalla-models:0.0.8'
3944
```
4045

46+
## GitHub Packages
47+
48+
### Triggering a Publish
49+
50+
Go to the **Actions** tab → select **"Publish to GitHub Packages"** → click **"Run workflow"**.
51+
52+
No inputs required. The published version is whatever is set in `settings.gradle.kts`.
53+
54+
### Consuming from GitHub Packages
55+
56+
GitHub Packages requires authentication even for public packages. Create a GitHub Personal Access Token (PAT) with the `read:packages` scope and store credentials in `~/.gradle/gradle.properties` (never commit this file):
57+
58+
```properties
59+
gpr.user=YOUR_GITHUB_USERNAME
60+
gpr.key=YOUR_GITHUB_PAT
61+
```
62+
63+
Add the repository to your project's `settings.gradle.kts`:
64+
65+
```kotlin
66+
dependencyResolutionManagement {
67+
repositories {
68+
maven {
69+
name = "GitHubPackages"
70+
url = uri("https://maven.pkg.github.com/OWNER/REPO")
71+
credentials {
72+
username = providers.gradleProperty("gpr.user").orNull ?: System.getenv("GITHUB_ACTOR")
73+
password = providers.gradleProperty("gpr.key").orNull ?: System.getenv("GITHUB_TOKEN")
74+
}
75+
}
76+
}
77+
}
78+
```
79+
80+
Replace `OWNER/REPO` with the actual repository path (e.g. `gabrielsamojlo/valhalla-openapi-models-kotlin`).
81+
82+
Then add dependencies as usual:
83+
84+
```kotlin
85+
implementation("io.github.rallista:valhalla-models:0.1.1")
86+
implementation("io.github.rallista:valhalla-models-config:0.1.1")
87+
```
88+
4189
## What's Using It
4290

4391
- [valhalla-mobile](https://github.com/Rallista/valhalla-mobile) - A valhalla wrapper library built for Android & iOS.

client/build.gradle.kts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ val libraryVersion: String by extra
7171

7272
mavenPublishing {
7373
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
74-
signAllPublications()
74+
if (project.findProperty("signPublications") != "false") {
75+
signAllPublications()
76+
}
7577

7678
if (libraryVersion == "unspecified") {
7779
throw GradleException("libraryVersion must be specified in settings.gradle.kts")
@@ -107,4 +109,17 @@ mavenPublishing {
107109
url.set(ProjectConfig.SCM_URL)
108110
}
109111
}
110-
}
112+
}
113+
114+
publishing {
115+
repositories {
116+
maven {
117+
name = "GitHubPackages"
118+
url = uri("https://maven.pkg.github.com/valhalla-openapi-models-kotlin")
119+
credentials {
120+
username = System.getenv("GITHUB_ACTOR")
121+
password = System.getenv("GITHUB_TOKEN")
122+
}
123+
}
124+
}
125+
}

config/build.gradle.kts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ val libraryVersion: String by extra
7373

7474
mavenPublishing {
7575
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
76-
signAllPublications()
76+
if (project.findProperty("signPublications") != "false") {
77+
signAllPublications()
78+
}
7779

7880
if (libraryVersion == "unspecified") {
7981
throw GradleException("libraryVersion must be specified in settings.gradle.kts")
@@ -109,4 +111,17 @@ mavenPublishing {
109111
url.set(ProjectConfig.SCM_URL)
110112
}
111113
}
112-
}
114+
}
115+
116+
publishing {
117+
repositories {
118+
maven {
119+
name = "GitHubPackages"
120+
url = uri("https://maven.pkg.github.com/valhalla-openapi-models-kotlin")
121+
credentials {
122+
username = System.getenv("GITHUB_ACTOR")
123+
password = System.getenv("GITHUB_TOKEN")
124+
}
125+
}
126+
}
127+
}

0 commit comments

Comments
 (0)