From cd338b4cb5af6f02fb235a892449a4b4788f1567 Mon Sep 17 00:00:00 2001 From: langua Date: Mon, 19 Aug 2024 22:06:29 +0200 Subject: [PATCH] (ci) fix file path & add task for package publish at nyaaci --- .github/workflows/package-publish.yml | 41 +++++++++++++++++++++++++++ src/main/Jenkinsfile => Jenkinsfile | 3 +- build.gradle.kts | 22 ++++++++++++-- 3 files changed, 61 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/package-publish.yml rename src/main/Jenkinsfile => Jenkinsfile (79%) diff --git a/.github/workflows/package-publish.yml b/.github/workflows/package-publish.yml new file mode 100644 index 0000000..8536e6f --- /dev/null +++ b/.github/workflows/package-publish.yml @@ -0,0 +1,41 @@ +# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created +# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path +# also ref: +# Publishing packages to GitHub Packages: +# https://docs.github.com/en/actions/use-cases-and-examples/publishing-packages/publishing-java-packages-with-maven#publishing-packages-to-github-packages +# +# Upgrade to Automatic token authentication, no need for personal access token anymore +# ref: https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#upgrading-a-workflow-that-accesses-a-registry-using-a-personal-access-token +# + +name: Publish to GitHub Packages + +run-name: 'Package Publish #${{github.run_number}}' + +on: + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + permissions: + packages: write + contents: read + + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Set up JDK + uses: actions/setup-java@v4 + with: + java-version: '21' + distribution: 'oracle' + server-id: 'github-package' + + - name: Publish to GitHub Packages Apache Maven + run: ./gradlew publishToGithubPackage + env: + GITHUB_MAVEN_URL: https://maven.pkg.github.com/${{github.repository}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} \ No newline at end of file diff --git a/src/main/Jenkinsfile b/Jenkinsfile similarity index 79% rename from src/main/Jenkinsfile rename to Jenkinsfile index d9c8042..fb464f0 100644 --- a/src/main/Jenkinsfile +++ b/Jenkinsfile @@ -1,4 +1,3 @@ - pipeline { agent any stages { @@ -7,7 +6,7 @@ pipeline { jdk "jdk21" } steps { - sh './gradlew build' + sh './gradlew publishMavenJavaPublicationToNyaaCatCILocalRepository' } } } diff --git a/build.gradle.kts b/build.gradle.kts index 887524a..0283f7c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -34,18 +34,34 @@ publishing { create("mavenJava") { from(components["java"]) groupId = project.group.toString() - artifactId = "lockettepro" + artifactId = rootProject.name.lowercase() version = project.version.toString() } } repositories { maven { - name = "github-package" - url = URI(System.getenv("GITHUB_MAVEN_URL") ?: "https://github.com") + name = "GithubPackage" + url = + URI(System.getenv("GITHUB_MAVEN_URL") ?: "https://github.com/") credentials { username = System.getenv("GITHUB_ACTOR") password = System.getenv("GITHUB_TOKEN") } } + maven { + name = "NyaaCatCILocal" + //local maven repository + url = uri("file://${System.getenv("MAVEN_DIR")}") + } } +} + +// Custom tasks for publishing to specific repositories +tasks.register("publishToGithubPackage") { + dependsOn("publishMavenJavaPublicationToGithubPackageRepository") + // auto generated task: publishPublicationToRepository +} + +tasks.register("publishToNyaaCatCILocal") { + dependsOn("publishMavenJavaPublicationToNyaaCatCILocalRepository") } \ No newline at end of file