Skip to content

Commit 7c7ca17

Browse files
committed
chore: Add the ability to publish to Github packages
Signed-off-by: Avior <[email protected]>
1 parent 238c215 commit 7c7ca17

File tree

3 files changed

+61
-20
lines changed

3 files changed

+61
-20
lines changed

.github/workflows/build.yml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,36 @@
55
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
66
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
77

8-
name: Java CI with Gradle
8+
name: Build & test the project
99

1010
on:
1111
push:
12-
branches: [ master ]
12+
branches:
13+
- master
14+
# Run on any pull request
1315
pull_request:
14-
branches: [ master ]
15-
16-
permissions:
17-
contents: read
1816

1917
jobs:
2018
build:
2119

2220
runs-on: ubuntu-latest
21+
2322
strategy:
2423
matrix:
2524
# follows https://en.wikipedia.org/wiki/Java_version_history#Release_table
2625
java-versions: ['8', '11', '17', '21']
2726

2827
steps:
29-
- uses: actions/checkout@v3
28+
- name: Checkout
29+
uses: actions/checkout@v3
30+
3031
- name: Set up Java ${{ matrix.java-versions }}
3132
uses: actions/setup-java@v3
3233
with:
3334
java-version: ${{ matrix.java-versions }}
3435
distribution: 'temurin'
35-
- name: Build with Gradle
36-
uses: gradle/gradle-build-action@fec4a42eb0c83154e5c9590748ba8337949c5701
36+
37+
- name: Build & Test
38+
uses: gradle/gradle-build-action@v2
3739
with:
38-
arguments: build
40+
arguments: build test

.github/workflows/publish.yml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,34 @@ name: Gradle Package
99

1010
on:
1111
release:
12-
types: [created]
12+
types:
13+
- created
1314

1415
jobs:
1516
build:
1617

1718
runs-on: ubuntu-latest
18-
permissions:
19-
contents: read
20-
packages: write
2119

2220
steps:
23-
- uses: actions/checkout@v3
24-
- name: Set up JDK 11
21+
- name: Checkout
22+
uses: actions/checkout@v3
23+
- name: Set up JDK 8
2524
uses: actions/setup-java@v3
2625
with:
27-
java-version: '11'
26+
java-version: '8' # use the lowest version from https://en.wikipedia.org/wiki/Java_version_history#Release_table
2827
distribution: 'temurin'
2928
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
3029
settings-path: ${{ github.workspace }} # location for the settings.xml file
3130

32-
- name: Build with Gradle
33-
uses: gradle/gradle-build-action@fec4a42eb0c83154e5c9590748ba8337949c5701
31+
- name: Build the project
32+
uses: gradle/gradle-build-action@v2
3433
with:
3534
arguments: build
3635

3736
# The USERNAME and TOKEN need to correspond to the credentials environment variables used in
3837
# the publishing section of your build.gradle
3938
- name: Publish to GitHub Packages
40-
uses: gradle/gradle-build-action@fec4a42eb0c83154e5c9590748ba8337949c5701
39+
uses: gradle/gradle-build-action@v2
4140
with:
4241
arguments: publish
4342
env:

build.gradle.kts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,45 @@ publishing {
8585
}
8686
}
8787
}
88+
register<MavenPublication>("gpr") {
89+
// groupId = group
90+
artifactId = artifact
91+
// version = ver
92+
93+
from(components["java"])
94+
95+
pom {
96+
name.set("TCGdex SDK")
97+
description.set("Communicate with the Open Source TCGdex API in Kotlin/Java using the SDK")
98+
url.set("https://github.com/tcgdex/java-sdk")
99+
licenses {
100+
license {
101+
name.set("MIT License")
102+
url.set("https://github.com/tcgdex/java-sdk/blob/master/LICENSE.txt")
103+
}
104+
}
105+
developers {
106+
developer {
107+
id.set("avior")
108+
name.set("Avior")
109+
email.set("[email protected]")
110+
}
111+
}
112+
scm {
113+
connection.set("scm:[email protected]:tcgdex/java-sdk.git")
114+
url.set("https://github.com/tcgdex/java-sdk")
115+
}
116+
}
117+
}
118+
}
119+
repositories {
120+
maven {
121+
name = "GithubPackages"
122+
url = uri("https://maven.pkg.github.com/tcgdex/java-sdk")
123+
credentials {
124+
username = project.findProperty("gpr.user") as String? ?: System.getenv("USERNAME")
125+
password = project.findProperty("gpr.key") as String? ?: System.getenv("TOKEN")
126+
}
127+
}
88128
}
89129
}

0 commit comments

Comments
 (0)