From 4ff259a6271e6ebd3997e7054320d6339846fd64 Mon Sep 17 00:00:00 2001 From: C0D3 M4513R <28912031+C0D3-M4513R@users.noreply.github.com> Date: Sat, 23 Dec 2023 15:28:04 +0100 Subject: [PATCH 1/2] maven publications test1 --- .github/workflows/gradle-publish.yml | 105 +++++++++++++++++++++++++++ build.gradle | 82 ++++++++++++++++++++- 2 files changed, 186 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/gradle-publish.yml diff --git a/.github/workflows/gradle-publish.yml b/.github/workflows/gradle-publish.yml new file mode 100644 index 0000000..666ccdd --- /dev/null +++ b/.github/workflows/gradle-publish.yml @@ -0,0 +1,105 @@ +name: Gradle Package + +on: + push: + branches: [master] + tags: + - v* + pull_request: + branches: [master] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Get Version Name + id: version_name + run: | + echo version=${GITHUB_REF#refs/tags/v} >> $GITHUB_OUTPUT + - name: Set up JDK + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + server-id: github # Value of the distributionManagement/repository/id field of the pom.xml + settings-path: ${{ github.workspace }} # location for the settings.xml file + - name: Validate Gradle wrapper + uses: gradle/wrapper-validation-action@v1 + - name: Build with Gradle + uses: gradle/gradle-build-action@v2.9.0 + with: + arguments: build + env: + VERSION: ${{ steps.version_name.outputs.version }} + + - name: Generate Release Hash + id: hash + run: echo "$(git rev-parse --short HEAD)" > hash.env + + - name: Upload Build Artifact + uses: actions/upload-artifact@v3 + with: + name: jar + path: build/libs/kettingcore.jar + + - name: Upload Hash + uses: actions/upload-artifact@v3 + with: + name: hash + path: hash.env + + + release: + needs: build + runs-on: ubuntu-latest + if: github.ref_type == 'tag' + permissions: + contents: write + packages: write + + steps: + - uses: actions/checkout@v3 + - name: Download Build Artifact + uses: actions/download-artifact@v3 + with: + name: jar + path: tmp + + - name: Download Hash + uses: actions/download-artifact@v3 + with: + name: hash + path: tmp + - name: Get Version Name + id: version_name + run: | + echo version=${GITHUB_REF#refs/tags/v} >> $GITHUB_OUTPUT + - name: Set up JDK + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + server-id: github # Value of the distributionManagement/repository/id field of the pom.xml + settings-path: ${{ github.workspace }} # location for the settings.xml file + - name: Validate Gradle wrapper + uses: gradle/wrapper-validation-action@v1 + - name: Build with Gradle + uses: gradle/gradle-build-action@v2.9.0 + with: + arguments: publish + env: + KETTINGUSERNAME: ${{ secrets.KETTINGUSERNAME }} + KETTINGPASSWORD: ${{ secrets.KETTINGPASSWORD }} + VERSION: ${{ steps.version_name.outputs.version }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Create Release + run: | + gh release create "v$VERSION" tmp/kettingcore*.jar \ + --repo="$GITHUB_REPOSITORY" \ + --title="${GITHUB_REPOSITORY#*/} v$VERSION" \ + --generate-notes + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + VERSION: ${{ steps.version_name.outputs.version }} diff --git a/build.gradle b/build.gradle index 4dc2137..878344e 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,6 @@ plugins { } group = 'org.kettingpowered' -version = '1.0.0' repositories { mavenCentral() @@ -21,7 +20,88 @@ jar { archiveClassifier.set('') archiveExtension.set('jar') + manifest { + attributes 'Specification-Title': 'Kettingpowered', + 'Specification-Vendor': 'Kettingpowered', + 'Implementation-Title': 'KettingCore', + 'Implementation-Version': System.getenv("VERSION") ?: 'dev-ver', + 'Implementation-Vendor': 'Kettingpowered' + } + from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } +} + +task sourcesJar(type: Jar, dependsOn: classes) { + archiveClassifier = 'sources' + from sourceSets.main.allSource +} + +task javadocJar(type: Jar, dependsOn: javadoc) { + archiveClassifier = 'javadoc' + from javadoc.destinationDir +} + +publishing { + publications { + myPublication(MavenPublication) { + from components.java + artifact(sourcesJar) { + // These values will be used instead of the values from the task. The task values will not be updated. + classifier "sources" + extension "jar" + } + artifact(javadocJar) { + //These values will be used instead of the values from the task. The task values will not be updated. + classifier "javadoc" + extension "jar" + } +// artifact jar +// groupId = "org.kettingpowered" +// artifactId = "terminal-colors" + version = System.getenv("VERSION") + pom { + name = "KettingCore" + description = "An API supported across all Ketting Versions" + url = "https://github.com/kettingpowered/terminal-colors" + licenses { + license { + name = "MIT License" + url = "http://www.opensource.org/licenses/mit-license.php" + } + } + developers { + developer { + id = "justred23" + name = "JustRed23" + //email = "jon@doe" + } + } + scm { + connection = "scm:git:https://github.com/kettingpowered/terminal-colors.git" + //developerConnection = "scm:svn:https://subversion.example.com/svn/project/trunk/" + url = "https://github.com/kettingpowered/terminal-colors" + } + } + } + } + repositories { + maven { + name = "GitHubPackages" + url = uri("https://maven.pkg.github.com/kettingpowered/terminal-colors") + credentials { + username = System.getenv("GITHUB_ACTOR") + password = System.getenv("GITHUB_TOKEN") + } + } + maven { + name = 'kettingRepo' + credentials { + username = System.getenv("KETTINGUSERNAME") + password = System.getenv("KETTINGPASSWORD") + } + url = "https://nexus.c0d3m4513r.com/repository/Ketting/" + } + } } \ No newline at end of file From 92480b4b3173a4d7c019608c1a6c325bbfc9da6f Mon Sep 17 00:00:00 2001 From: C0D3 M4513R <28912031+C0D3-M4513R@users.noreply.github.com> Date: Sat, 23 Dec 2023 15:33:04 +0100 Subject: [PATCH 2/2] maven publications test2 --- build.gradle | 1 + gradlew | 0 2 files changed, 1 insertion(+) mode change 100644 => 100755 gradlew diff --git a/build.gradle b/build.gradle index 878344e..10ea4bb 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,6 @@ plugins { id 'java-library' + id 'maven-publish' } group = 'org.kettingpowered' diff --git a/gradlew b/gradlew old mode 100644 new mode 100755