Skip to content

Commit ecdfd24

Browse files
authored
Merge pull request #60 from AxenoDev/copilot/add-noctisui-build-dependency
Configure Maven publishing for GitHub Packages
2 parents 0437e9c + 6d55482 commit ecdfd24

File tree

7 files changed

+206
-3
lines changed

7 files changed

+206
-3
lines changed

.github/workflows/release-published.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,36 @@ on:
44
types: [published]
55

66
jobs:
7+
publish-maven:
8+
runs-on: ubuntu-latest
9+
permissions:
10+
contents: read
11+
packages: write
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Set up JDK 21
19+
uses: actions/setup-java@v4
20+
with:
21+
java-version: '21'
22+
distribution: 'temurin'
23+
24+
- name: Make gradlew executable
25+
run: chmod +x gradlew
26+
27+
- name: Publish to GitHub Packages
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
30+
GITHUB_ACTOR: ${{ github.actor }}
31+
TAG: ${{ github.event.release.tag_name }}
32+
run: ./gradlew publish
33+
734
notify-discord:
835
runs-on: ubuntu-latest
36+
needs: publish-maven
937
steps:
1038
- name: Checkout repository
1139
uses: actions/checkout@v4

README.MD

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,33 @@ Ce framework puissant vous donne les outils nécessaires pour concevoir des menu
1818
> Il peut donc contenir des **bugs** / des **problèmes de performance**.
1919
> N'hésitez pas à nous faire part de vos retours, dans les [issues du repo](https://github.com/Libnaus/NoctisUI/issues).
2020
21+
### 📦 Utilisation comme dépendance
22+
23+
NoctisUI est disponible sur GitHub Packages et peut être utilisé comme dépendance dans vos mods Fabric.
24+
25+
#### Installation rapide
26+
27+
Ajoutez à votre `build.gradle`:
28+
29+
```gradle
30+
repositories {
31+
maven {
32+
name = "GitHubPackages"
33+
url = uri("https://maven.pkg.github.com/AxenoDev/NoctisUI")
34+
credentials {
35+
username = project.findProperty("gpr.user") ?: System.getenv("GITHUB_ACTOR")
36+
password = project.findProperty("gpr.token") ?: System.getenv("GITHUB_TOKEN")
37+
}
38+
}
39+
}
40+
41+
dependencies {
42+
modImplementation "fr.libnaus:noctisui:1.0.0"
43+
}
44+
```
45+
46+
Pour plus de détails sur l'installation et la configuration, consultez [MAVEN_PUBLISHING.md](MAVEN_PUBLISHING.md).
47+
2148
### Contribution
2249
1. Forkez le projet
2350
2. Assurez-vous de bien suivre les [conventions de contribution](CONTRIBUTING.md)

build.gradle

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,55 @@ jar {
102102
publishing {
103103
publications {
104104
create("mavenJava", MavenPublication) {
105+
groupId = project.maven_group
105106
artifactId = project.archives_base_name
107+
version = project.version
108+
106109
from components.java
110+
111+
pom {
112+
name = 'NoctisUI'
113+
description = 'A Minecraft UI library for creating custom and interactive user interfaces'
114+
url = 'https://github.com/AxenoDev/NoctisUI'
115+
116+
licenses {
117+
license {
118+
name = 'GNU General Public License v3.0'
119+
url = 'https://www.gnu.org/licenses/gpl-3.0.html'
120+
}
121+
}
122+
123+
developers {
124+
developer {
125+
id = 'AxenoDev'
126+
name = 'Timéo B.'
127+
email = 'tbavart@gmail.com'
128+
}
129+
}
130+
131+
scm {
132+
connection = 'scm:git:git://github.com/AxenoDev/NoctisUI.git'
133+
developerConnection = 'scm:git:ssh://github.com:AxenoDev/NoctisUI.git'
134+
url = 'https://github.com/AxenoDev/NoctisUI'
135+
}
136+
}
107137
}
108138
}
109139

110-
repositories {}
140+
repositories {
141+
// GitHub Packages repository
142+
maven {
143+
name = "GitHubPackages"
144+
url = uri("https://maven.pkg.github.com/AxenoDev/NoctisUI")
145+
credentials {
146+
username = System.getenv("GITHUB_ACTOR")
147+
password = System.getenv("GITHUB_TOKEN")
148+
}
149+
}
150+
151+
// Local Maven repository for testing
152+
mavenLocal()
153+
}
111154
}
112155

113156
tasks.jar {

docs/getting-started.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,13 @@ NoctisUI is a powerful UI library for Minecraft (Fabric) that provides developer
2121

2222
```gradle
2323
repositories {
24-
// Add the repository where NoctisUI is published
2524
maven {
26-
url = "https://your-maven-repo-url"
25+
name = "GitHubPackages"
26+
url = uri("https://maven.pkg.github.com/AxenoDev/NoctisUI")
27+
credentials {
28+
username = project.findProperty("gpr.user") ?: System.getenv("GITHUB_ACTOR")
29+
password = project.findProperty("gpr.token") ?: System.getenv("GITHUB_TOKEN")
30+
}
2731
}
2832
}
2933
@@ -43,6 +47,18 @@ dependencies {
4347
}
4448
```
4549

50+
::: tip Authentication for GitHub Packages
51+
To access GitHub Packages, you need to provide credentials. You can:
52+
- Add them to your `~/.gradle/gradle.properties`:
53+
```properties
54+
gpr.user=YOUR_GITHUB_USERNAME
55+
gpr.token=YOUR_GITHUB_TOKEN
56+
```
57+
- Or set environment variables `GITHUB_ACTOR` and `GITHUB_TOKEN`
58+
59+
You can generate a personal access token at [GitHub Settings > Developer settings > Personal access tokens](https://github.com/settings/tokens) with `read:packages` permission.
60+
:::
61+
4662
### For Players
4763

4864
1. Download the latest version of NoctisUI from the releases page

gradlew

100644100755
File mode changed.

settings.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,9 @@ pluginManagement {
77
gradlePluginPortal()
88
}
99
}
10+
11+
dependencyResolutionManagement {
12+
repositories {
13+
mavenCentral()
14+
}
15+
}

test-publish.sh

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#!/bin/bash
2+
# Script to test Maven publishing locally
3+
4+
echo "==========================================="
5+
echo "NoctisUI Maven Publishing Test"
6+
echo "==========================================="
7+
echo ""
8+
9+
# Make gradlew executable
10+
chmod +x gradlew
11+
12+
# Test 1: Publish to local Maven repository
13+
echo "Test 1: Publishing to local Maven repository..."
14+
echo "-------------------------------------------"
15+
./gradlew publishToMavenLocal
16+
17+
if [ $? -eq 0 ]; then
18+
echo "✓ Successfully published to local Maven repository"
19+
echo ""
20+
21+
# Check if the artifact was created
22+
MAVEN_LOCAL=~/.m2/repository
23+
ARTIFACT_PATH="$MAVEN_LOCAL/fr/libnaus/noctisui"
24+
25+
if [ -d "$ARTIFACT_PATH" ]; then
26+
echo "✓ Artifact found at: $ARTIFACT_PATH"
27+
echo ""
28+
echo "Published versions:"
29+
ls -la "$ARTIFACT_PATH"
30+
echo ""
31+
else
32+
echo "✗ Artifact not found at expected location: $ARTIFACT_PATH"
33+
fi
34+
else
35+
echo "✗ Failed to publish to local Maven repository"
36+
exit 1
37+
fi
38+
39+
# Test 2: Show generated POM
40+
echo ""
41+
echo "Test 2: Checking generated POM..."
42+
echo "-------------------------------------------"
43+
POM_FILE=$(find build/publications/mavenJava -name "*.pom" 2>/dev/null | head -1)
44+
45+
if [ -n "$POM_FILE" ] && [ -f "$POM_FILE" ]; then
46+
echo "✓ POM file found: $POM_FILE"
47+
echo ""
48+
echo "POM content:"
49+
cat "$POM_FILE"
50+
echo ""
51+
else
52+
echo "✗ POM file not found"
53+
fi
54+
55+
# Test 3: List published artifacts
56+
echo ""
57+
echo "Test 3: Listing published artifacts..."
58+
echo "-------------------------------------------"
59+
if [ -d "build/publications/mavenJava" ]; then
60+
echo "✓ Publications directory exists"
61+
echo ""
62+
echo "Generated files:"
63+
find build/publications/mavenJava -type f
64+
echo ""
65+
else
66+
echo "✗ Publications directory not found"
67+
fi
68+
69+
echo ""
70+
echo "==========================================="
71+
echo "Testing complete!"
72+
echo "==========================================="
73+
echo ""
74+
echo "To use this artifact in another project, add to build.gradle:"
75+
echo ""
76+
echo "repositories {"
77+
echo " mavenLocal()"
78+
echo "}"
79+
echo ""
80+
echo "dependencies {"
81+
echo " modImplementation 'fr.libnaus:noctisui:<version>'"
82+
echo "}"
83+
echo ""

0 commit comments

Comments
 (0)