File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : CI
2+
3+ on :
4+ push :
5+ branches :
6+ - master
7+ workflow_dispatch :
8+
9+ permissions :
10+ contents : read
11+
12+ jobs :
13+ build-and-test :
14+ runs-on : ubuntu-latest
15+ permissions :
16+ packages : write
17+ steps :
18+ - uses : actions/checkout@v4
19+
20+ - name : Set up JDK 17
21+ uses : actions/setup-java@v4
22+ with :
23+ java-version : ' 17'
24+ distribution : ' temurin'
25+
26+ - name : Setup Gradle
27+ uses : gradle/actions/setup-gradle@v3
28+
29+ - name : Publish package
30+ run : |
31+ COMMIT_SHA="`git log -n 1 --pretty=format:%H`" ./gradlew publish
32+ env :
33+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
Original file line number Diff line number Diff line change 1+ import java.net.URI
2+
13plugins {
24 alias(libs.plugins.org.jetbrains.kotlin.jvm)
35 id(" java-library" )
6+ id(" maven-publish" )
47}
58
69kotlin {
@@ -11,3 +14,31 @@ dependencies {
1114 implementation(libs.nanojson)
1215 testImplementation(libs.junit)
1316}
17+
18+ val sourcesJar by tasks.registering(Jar ::class ) {
19+ archiveClassifier.convention(" sources" );
20+ archiveClassifier.set(" sources" );
21+ from(sourceSets.main.get().allSource)
22+ }
23+
24+ publishing {
25+ repositories {
26+ maven {
27+ name = " GitHubPackages"
28+ url = URI (" https://maven.pkg.github.com/octocat/hello-world" )
29+ credentials {
30+ username = System .getenv(" GITHUB_ACTOR" )
31+ password = System .getenv(" GITHUB_TOKEN" )
32+ }
33+ }
34+ }
35+ publications {
36+ register(" mavenJava" , MavenPublication ::class ) {
37+ groupId = " org.dicio"
38+ artifactId = " numbers"
39+ version = System .getenv(" COMMIT_SHA" )
40+ from(components[" java" ])
41+ artifact(sourcesJar.get())
42+ }
43+ }
44+ }
You can’t perform that action at this time.
0 commit comments