Skip to content

Commit ea09dea

Browse files
committed
📝 Add build
1 parent fcb593c commit ea09dea

2 files changed

Lines changed: 87 additions & 6 deletions

File tree

.github/workflows/build.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Build Action
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
types: [ opened, synchronize, reopened ]
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
packages: write
13+
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.ref }}
16+
cancel-in-progress: true
17+
18+
jobs:
19+
build:
20+
name: Build and Publish CurrenciesAPI
21+
uses: GroupeZ-dev/actions/.github/workflows/build.yml@main
22+
with:
23+
project-name: "CurrenciesAPI"
24+
publish: true
25+
publish-on-discord: false
26+
project-to-publish: "publish"
27+
secrets:
28+
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
29+
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
30+
WEBHOOK_URL: ""

build.gradle.kts

Lines changed: 57 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
1+
import java.util.Locale
2+
13
plugins {
2-
java
4+
`java-library`
5+
id("com.github.johnrengelman.shadow") version "7.1.2" // Pour remplacer maven-shade-plugin
36
`maven-publish`
47
}
58

6-
group = "fr.traqueur"
9+
rootProject.extra.properties["sha"]?.let { sha ->
10+
version = sha
11+
}
12+
13+
group = "fr.traqueur.currencies"
714
version = property("version") as String
815

16+
extra.set("targetFolder", file("target/"))
17+
extra.set("classifier", System.getProperty("archive.classifier"))
18+
extra.set("sha", System.getProperty("github.sha"))
19+
920
repositories {
1021
mavenCentral()
1122
maven {
@@ -72,14 +83,54 @@ val generateVersionProperties by tasks.registering {
7283
}
7384
}
7485

75-
tasks.named("build") {
76-
dependsOn(generateVersionProperties)
86+
tasks.withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar> {
87+
archiveClassifier.set("") // Écrase le JAR de base par le fat jar
88+
}
89+
90+
tasks.build {
91+
dependsOn(tasks.shadowJar)
92+
}
93+
94+
tasks.withType<Jar> {
95+
manifest {
96+
attributes["Implementation-Title"] = "CurrenciesAPI"
97+
attributes["Implementation-Version"] = project.version
98+
}
7799
}
78100

79101
publishing {
102+
var repository = System.getProperty("repository.name", "snapshots").replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }
103+
104+
repositories {
105+
maven {
106+
name = "groupez${repository}"
107+
url = uri("https://repo.groupez.dev/${repository.lowercase()}")
108+
credentials {
109+
username = findProperty("${name}Username") as String? ?: System.getenv("MAVEN_USERNAME")
110+
password = findProperty("${name}Password") as String? ?: System.getenv("MAVEN_PASSWORD")
111+
}
112+
authentication {
113+
create<BasicAuthentication>("basic")
114+
}
115+
}
116+
}
117+
80118
publications {
81-
create<MavenPublication>("maven") {
82-
from(components["java"])
119+
register<MavenPublication>("groupez${repository}") {
120+
pom {
121+
groupId = project.group as String?
122+
artifactId = rootProject.name.lowercase()
123+
version = project.version as String?
124+
125+
scm {
126+
connection = "scm:git:git://github.com/GroupeZ-dev/${rootProject.name}.git"
127+
developerConnection = "scm:git:ssh://github.com/GroupeZ-dev/${rootProject.name}.git"
128+
url = "https://github.com/GroupeZ-dev/${rootProject.name}/"
129+
}
130+
}
131+
artifact(tasks.shadowJar)
132+
// artifact(tasks.javadocJar)
133+
// artifact(tasks.sourcesJar)
83134
}
84135
}
85136
}

0 commit comments

Comments
 (0)