Skip to content

Commit c2c4d15

Browse files
committed
feat: maven package + publish jar
1 parent a8d6492 commit c2c4d15

File tree

3 files changed

+44
-52
lines changed

3 files changed

+44
-52
lines changed

.github/workflows/build.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,19 @@ jobs:
2424
distribution: 'temurin'
2525

2626
- name: Build with Gradle
27-
run: ./gradlew build
27+
run: ./gradlew build
28+
29+
- name: Upload JAR file
30+
uses: actions/upload-artifact@v4
31+
with:
32+
name: Artifacts
33+
path: build/libs/*.jar
34+
35+
- name: Publish
36+
if: github.ref == 'refs/heads/main' && github.repository_owner == 'SuperCrafting'
37+
env:
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
GITHUB_USERNAME: ${{ github.repository_owner }}
40+
GITHUB_REPOSITORY: ${{ github.repository }}
41+
BUILD_VERSION: ${{ github.run_number }}
42+
run: ./gradlew publish

.github/workflows/release.yml

Lines changed: 0 additions & 51 deletions
This file was deleted.

build.gradle

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
plugins {
22
id 'java'
3+
id 'maven-publish'
34
}
45

56
group = 'pt.supercrafting.menu'
@@ -28,4 +29,31 @@ dependencies {
2829

2930
test {
3031
useJUnitPlatform()
32+
}
33+
34+
publishing {
35+
36+
publications {
37+
maven(MavenPublication) {
38+
groupId = project.group
39+
artifactId = 'menu-api'
40+
version = project.version
41+
42+
from components.java
43+
}
44+
}
45+
46+
repositories {
47+
maven {
48+
credentials {
49+
username System.getenv('GITHUB_USERNAME')
50+
password System.getenv('GITHUB_TOKEN')
51+
}
52+
name = "menu-api"
53+
54+
String owner = System.getenv('GITHUB_USERNAME')
55+
String repository = System.getenv('GITHUB_REPOSITORY') ?: 'menu-api'
56+
url = "https://maven.pkg.github.com/" + owner "/" + repository
57+
}
58+
}
3159
}

0 commit comments

Comments
 (0)