Skip to content

Commit 17c7bba

Browse files
authored
[ci] Maven publish (#2)
1 parent 94368d5 commit 17c7bba

File tree

5 files changed

+64
-9
lines changed

5 files changed

+64
-9
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support
4+
# documentation.
5+
# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created
6+
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle
7+
8+
name: Gradle Package
9+
10+
on:
11+
push:
12+
branches:
13+
- dev/3.0.0
14+
15+
jobs:
16+
build:
17+
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: read
21+
packages: write
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
- name: Set up JDK 21
26+
uses: actions/setup-java@v4
27+
with:
28+
java-version: '21'
29+
distribution: 'temurin'
30+
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
31+
settings-path: ${{ github.workspace }} # location for the settings.xml file
32+
33+
- name: Setup Gradle
34+
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
35+
36+
- name: Build with Gradle
37+
run: ./gradlew build
38+
39+
# The USERNAME and TOKEN need to correspond to the credentials environment variables used in
40+
# the publishing section of your build.gradle
41+
- name: Publish to GitHub Packages
42+
run: ./gradlew publish
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build-logic/src/main/kotlin/velocity-publish.gradle.kts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,24 @@ plugins {
33
`maven-publish`
44
}
55

6+
val isCi = System.getenv("GITHUB_EVENT_NAME") != null
7+
68
extensions.configure<PublishingExtension> {
79
repositories {
8-
maven {
9-
credentials(PasswordCredentials::class.java)
10-
11-
name = if (version.toString().endsWith("SNAPSHOT")) "paperSnapshots" else "paper" // "paper" is seemingly not defined
12-
val base = "https://artifactory.papermc.io/artifactory"
13-
val releasesRepoUrl = "$base/releases/"
14-
val snapshotsRepoUrl = "$base/snapshots/"
15-
setUrl(if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl)
10+
if (isCi) {
11+
repositories {
12+
maven {
13+
name = "GitHubPackages"
14+
url = uri("https://maven.pkg.github.com/poweredbyapartium/velocity")
15+
credentials {
16+
username = System.getenv("GITHUB_ACTOR")
17+
password = System.getenv("GITHUB_TOKEN")
18+
}
19+
}
20+
}
1621
}
1722
}
23+
1824
publications {
1925
create<MavenPublication>("maven") {
2026
from(components["java"])

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
group=com.velocitypowered
1+
group=dev.apartium.velocity
22
version=3.4.0-SNAPSHOT

proxy/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ plugins {
66
id("velocity-init-manifest")
77
alias(libs.plugins.shadow)
88
alias(libs.plugins.fill)
9+
id("velocity-publish")
910
}
1011

1112
application {

proxy/log4j2-plugin/build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
plugins {
2+
id("velocity-publish")
3+
}
4+
15
dependencies {
26
implementation(libs.bundles.log4j)
37
annotationProcessor(libs.log4j.core)

0 commit comments

Comments
 (0)