From fd3933df2598a2a6066714436c5a2f78931d03dd Mon Sep 17 00:00:00 2001 From: tueem Date: Wed, 13 Nov 2024 10:22:25 +0100 Subject: [PATCH 01/10] add publications --- build.gradle.kts | 50 ++++++++++++++++++++++++ gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew | 0 settings.gradle.kts | 6 ++- 4 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 build.gradle.kts mode change 100644 => 100755 gradlew diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..ef41a19 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,50 @@ +import java.io.ByteArrayOutputStream + +plugins { + `maven-publish` +} + +allprojects { + group = "net.tomatentum.Marinara" + version = "1.0.0-RC1" + (if (!project.hasProperty("release")) ("-" + getGitHash()) else "") + description = "A simple but powerful, library-agnostic Discord Interaction Wrapper." +} + +subprojects { + apply(plugin = "maven-publish") + apply(plugin = "java-library") + + plugins.withType { + publishing { + publications { + create("maven") { + from(components["java"]) + } + } + + repositories { + maven { + name = "Gitea" + url = uri("https://git.tomatentum.net/api/packages/tueem/maven/") + + credentials(HttpHeaderCredentials::class) { + name = "Authorization" + value = "token " + System.getenv("GITEA_TOKEN") + } + authentication { + create("header") + } + } + } + } + } +} + +fun getGitHash(): String { + val output = ByteArrayOutputStream() + project.exec { + commandLine("git", "rev-parse", "--short", "HEAD") + standardOutput = output + } + return output.toString().trim() +} \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a441313..94113f2 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 diff --git a/settings.gradle.kts b/settings.gradle.kts index 7ccb161..06c8680 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -11,5 +11,7 @@ plugins { } rootProject.name = "Marinara" -include("lib") -include("wrapper:javacord") +include(":lib") +include(":wrapper-javacord") + +project(":wrapper-javacord").projectDir = file("wrapper/javacord") -- 2.45.2 From de831378866abafbcdaba5f7e06363505acfc783 Mon Sep 17 00:00:00 2001 From: tueem Date: Thu, 14 Nov 2024 11:53:08 +0100 Subject: [PATCH 02/10] add first version of CI with build, test and publish --- .gitea/workflows/gradle-build.yaml | 40 ++++++++++++++++++++++++++++ .gitea/workflows/gradle-publish.yaml | 31 +++++++++++++++++++++ .gitea/workflows/gradle-test.yaml | 38 ++++++++++++++++++++++++++ gradle.properties | 1 + 4 files changed, 110 insertions(+) create mode 100644 .gitea/workflows/gradle-build.yaml create mode 100644 .gitea/workflows/gradle-publish.yaml create mode 100644 .gitea/workflows/gradle-test.yaml create mode 100644 gradle.properties diff --git a/.gitea/workflows/gradle-build.yaml b/.gitea/workflows/gradle-build.yaml new file mode 100644 index 0000000..61945c8 --- /dev/null +++ b/.gitea/workflows/gradle-build.yaml @@ -0,0 +1,40 @@ +name: Build + +on: + push: + +jobs: + Gradle Build: + + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up JDK + uses: actions/setup-java@v4 + with: + java-version: '23' + check-latest: true + distribution: 'zulu' + + - name: Cache Gradle dependencies + uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: Build + run: chmod +x gradlew; ./gradlew assemble + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: artifacts + path: | + lib/build/libs/*.jar + wrapper/javacord/build/libs/*.jar diff --git a/.gitea/workflows/gradle-publish.yaml b/.gitea/workflows/gradle-publish.yaml new file mode 100644 index 0000000..dbbb9bc --- /dev/null +++ b/.gitea/workflows/gradle-publish.yaml @@ -0,0 +1,31 @@ +name: Test + +on: + push: + branches: [master] + +jobs: + Gradle Test: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up JDK + uses: actions/setup-java@v4 + with: + java-version: '23' + check-latest: true + distribution: 'zulu' + + - name: Cache Gradle dependencies + uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: Publish + env: + GITEA_TOKEN: {{ secrets.PUBLISH_PACKAGE_TOKEN }} + run: chmod +x gradlew; ./gradlew publishAllPublicationsToGiteaRepository \ No newline at end of file diff --git a/.gitea/workflows/gradle-test.yaml b/.gitea/workflows/gradle-test.yaml new file mode 100644 index 0000000..8adeb5b --- /dev/null +++ b/.gitea/workflows/gradle-test.yaml @@ -0,0 +1,38 @@ +name: Test + +on: + push: + +jobs: + Gradle Test: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up JDK + uses: actions/setup-java@v4 + with: + java-version: '23' + check-latest: true + distribution: 'zulu' + + - name: Cache Gradle dependencies + uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: Test + env: + DISCORD_TEST_TOKEN: {{ secrets.DISCORD_TOKEN }} + run: chmod +x gradlew; ./gradlew test + + - name: Publish Test Results + if: always() + uses: dorny/test-reporter@v1 + with: + name: Test Results + path: build/test-results/test/*.xml + reporter: junit \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..5f1ed7b --- /dev/null +++ b/gradle.properties @@ -0,0 +1 @@ +org.gradle.caching=true \ No newline at end of file -- 2.45.2 From f31292c5b749cbe00931615548c5431d0321a631 Mon Sep 17 00:00:00 2001 From: tueem Date: Thu, 14 Nov 2024 12:23:41 +0100 Subject: [PATCH 03/10] switch artifact action to gitea one --- .gitea/workflows/gradle-build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/gradle-build.yaml b/.gitea/workflows/gradle-build.yaml index 61945c8..c1aa735 100644 --- a/.gitea/workflows/gradle-build.yaml +++ b/.gitea/workflows/gradle-build.yaml @@ -32,7 +32,7 @@ jobs: run: chmod +x gradlew; ./gradlew assemble - name: Upload artifact - uses: actions/upload-artifact@v4 + uses: christopherhx/gitea-upload-artifact@v4 with: name: artifacts path: | -- 2.45.2 From b28406b16b4ba1b695b133d1ba9ed39ec119a8aa Mon Sep 17 00:00:00 2001 From: tueem Date: Thu, 14 Nov 2024 12:38:31 +0100 Subject: [PATCH 04/10] update artifact directory structure --- .gitea/workflows/gradle-build.yaml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/gradle-build.yaml b/.gitea/workflows/gradle-build.yaml index c1aa735..03d0179 100644 --- a/.gitea/workflows/gradle-build.yaml +++ b/.gitea/workflows/gradle-build.yaml @@ -4,7 +4,7 @@ on: push: jobs: - Gradle Build: + Gradle-Build: runs-on: ubuntu-latest @@ -31,10 +31,11 @@ jobs: - name: Build run: chmod +x gradlew; ./gradlew assemble + - name: Move artifacts + run: mkdir artifacts; mv lib/build/libs/*.jar artifacts; mv wrapper/javacord/build/libs/*.jar artifacts; + - name: Upload artifact uses: christopherhx/gitea-upload-artifact@v4 with: name: artifacts - path: | - lib/build/libs/*.jar - wrapper/javacord/build/libs/*.jar + path: artifacts -- 2.45.2 From b371ea85209bfa618cb94b761eec9fac126602e9 Mon Sep 17 00:00:00 2001 From: tueem Date: Thu, 14 Nov 2024 12:45:43 +0100 Subject: [PATCH 05/10] add setup gradle step --- .gitea/workflows/gradle-build.yaml | 6 ++++++ .gitea/workflows/gradle-publish.yaml | 6 ++++++ .gitea/workflows/gradle-test.yaml | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/.gitea/workflows/gradle-build.yaml b/.gitea/workflows/gradle-build.yaml index 03d0179..9f89304 100644 --- a/.gitea/workflows/gradle-build.yaml +++ b/.gitea/workflows/gradle-build.yaml @@ -19,6 +19,12 @@ jobs: check-latest: true distribution: 'zulu' + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 + with: + add-job-summary: always + cache-cleanup: on-success + - name: Cache Gradle dependencies uses: actions/cache@v4 with: diff --git a/.gitea/workflows/gradle-publish.yaml b/.gitea/workflows/gradle-publish.yaml index dbbb9bc..46acead 100644 --- a/.gitea/workflows/gradle-publish.yaml +++ b/.gitea/workflows/gradle-publish.yaml @@ -16,6 +16,12 @@ jobs: check-latest: true distribution: 'zulu' + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 + with: + add-job-summary: always + cache-cleanup: on-success + - name: Cache Gradle dependencies uses: actions/cache@v4 with: diff --git a/.gitea/workflows/gradle-test.yaml b/.gitea/workflows/gradle-test.yaml index 8adeb5b..98410a5 100644 --- a/.gitea/workflows/gradle-test.yaml +++ b/.gitea/workflows/gradle-test.yaml @@ -14,6 +14,12 @@ jobs: java-version: '23' check-latest: true distribution: 'zulu' + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 + with: + add-job-summary: always + cache-cleanup: on-success - name: Cache Gradle dependencies uses: actions/cache@v4 -- 2.45.2 From 18d85edcf271e914fedf1ca0c410c6e47c7bfb1b Mon Sep 17 00:00:00 2001 From: tueem Date: Thu, 14 Nov 2024 13:05:36 +0100 Subject: [PATCH 06/10] fix formatting --- .gitea/workflows/gradle-publish.yaml | 47 +++++++++++---------- .gitea/workflows/gradle-test.yaml | 63 +++++++++++++++------------- 2 files changed, 58 insertions(+), 52 deletions(-) diff --git a/.gitea/workflows/gradle-publish.yaml b/.gitea/workflows/gradle-publish.yaml index 46acead..9a2d921 100644 --- a/.gitea/workflows/gradle-publish.yaml +++ b/.gitea/workflows/gradle-publish.yaml @@ -5,33 +5,36 @@ on: branches: [master] jobs: - Gradle Test: - - name: Checkout code - uses: actions/checkout@v4 + Gradle-Test: + runs-on: ubuntu-latest - - name: Set up JDK - uses: actions/setup-java@v4 - with: - java-version: '23' - check-latest: true - distribution: 'zulu' + steps: + - name: Checkout code + uses: actions/checkout@v4 - - name: Setup Gradle + - name: Set up JDK + uses: actions/setup-java@v4 + with: + java-version: '23' + check-latest: true + distribution: 'zulu' + + - name: Setup Gradle uses: gradle/actions/setup-gradle@v4 with: add-job-summary: always cache-cleanup: on-success - - name: Cache Gradle dependencies - uses: actions/cache@v4 - with: - path: | - ~/.gradle/caches - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} - restore-keys: | - ${{ runner.os }}-gradle- + - name: Cache Gradle dependencies + uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- - - name: Publish - env: - GITEA_TOKEN: {{ secrets.PUBLISH_PACKAGE_TOKEN }} - run: chmod +x gradlew; ./gradlew publishAllPublicationsToGiteaRepository \ No newline at end of file + - name: Publish + env: + GITEA_TOKEN: {{ secrets.PUBLISH_PACKAGE_TOKEN }} + run: chmod +x gradlew; ./gradlew publishAllPublicationsToGiteaRepository \ No newline at end of file diff --git a/.gitea/workflows/gradle-test.yaml b/.gitea/workflows/gradle-test.yaml index 98410a5..bdadc11 100644 --- a/.gitea/workflows/gradle-test.yaml +++ b/.gitea/workflows/gradle-test.yaml @@ -4,41 +4,44 @@ on: push: jobs: - Gradle Test: - - name: Checkout code - uses: actions/checkout@v4 + Gradle-Test: + runs-on: ubuntu-latest - - name: Set up JDK - uses: actions/setup-java@v4 - with: - java-version: '23' - check-latest: true - distribution: 'zulu' - - - name: Setup Gradle + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up JDK + uses: actions/setup-java@v4 + with: + java-version: '23' + check-latest: true + distribution: 'zulu' + + - name: Setup Gradle uses: gradle/actions/setup-gradle@v4 with: add-job-summary: always cache-cleanup: on-success - - name: Cache Gradle dependencies - uses: actions/cache@v4 - with: - path: | - ~/.gradle/caches - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} - restore-keys: | - ${{ runner.os }}-gradle- + - name: Cache Gradle dependencies + uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- - - name: Test - env: - DISCORD_TEST_TOKEN: {{ secrets.DISCORD_TOKEN }} - run: chmod +x gradlew; ./gradlew test + - name: Test + env: + DISCORD_TEST_TOKEN: {{ secrets.DISCORD_TOKEN }} + run: chmod +x gradlew; ./gradlew test - - name: Publish Test Results - if: always() - uses: dorny/test-reporter@v1 - with: - name: Test Results - path: build/test-results/test/*.xml - reporter: junit \ No newline at end of file + - name: Publish Test Results + if: always() + uses: dorny/test-reporter@v1 + with: + name: Test Results + path: build/test-results/test/*.xml + reporter: junit \ No newline at end of file -- 2.45.2 From df10c5476757adacc584148771dd50fed0a5f2c2 Mon Sep 17 00:00:00 2001 From: tueem Date: Thu, 14 Nov 2024 13:54:12 +0100 Subject: [PATCH 07/10] fix variable usage --- .gitea/workflows/gradle-publish.yaml | 2 +- .gitea/workflows/gradle-test.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/gradle-publish.yaml b/.gitea/workflows/gradle-publish.yaml index 9a2d921..f6d4da8 100644 --- a/.gitea/workflows/gradle-publish.yaml +++ b/.gitea/workflows/gradle-publish.yaml @@ -36,5 +36,5 @@ jobs: - name: Publish env: - GITEA_TOKEN: {{ secrets.PUBLISH_PACKAGE_TOKEN }} + GITEA_TOKEN: ${{ secrets.PUBLISH_PACKAGE_TOKEN }} run: chmod +x gradlew; ./gradlew publishAllPublicationsToGiteaRepository \ No newline at end of file diff --git a/.gitea/workflows/gradle-test.yaml b/.gitea/workflows/gradle-test.yaml index bdadc11..ad08536 100644 --- a/.gitea/workflows/gradle-test.yaml +++ b/.gitea/workflows/gradle-test.yaml @@ -35,7 +35,7 @@ jobs: - name: Test env: - DISCORD_TEST_TOKEN: {{ secrets.DISCORD_TOKEN }} + DISCORD_TEST_TOKEN: ${{ secrets.DISCORD_TOKEN }} run: chmod +x gradlew; ./gradlew test - name: Publish Test Results -- 2.45.2 From 420408fbdfe65c43c1c26f3ec1fcc40cbd7df318 Mon Sep 17 00:00:00 2001 From: tueem Date: Thu, 14 Nov 2024 14:11:57 +0100 Subject: [PATCH 08/10] switch to java-junit reporter --- .gitea/workflows/gradle-test.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/gradle-test.yaml b/.gitea/workflows/gradle-test.yaml index ad08536..ec9f1ec 100644 --- a/.gitea/workflows/gradle-test.yaml +++ b/.gitea/workflows/gradle-test.yaml @@ -43,5 +43,7 @@ jobs: uses: dorny/test-reporter@v1 with: name: Test Results - path: build/test-results/test/*.xml - reporter: junit \ No newline at end of file + path: | + lib/build/test-results/test/*.xml + wrapper/javacord/build/test-results/test/*.xml + reporter: java-junit \ No newline at end of file -- 2.45.2 From 2ab30a2bc1204d5e7ea2d41020a43c5324ad0859 Mon Sep 17 00:00:00 2001 From: tueem Date: Thu, 14 Nov 2024 14:32:55 +0100 Subject: [PATCH 09/10] switch to comma seperation --- .gitea/workflows/gradle-test.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.gitea/workflows/gradle-test.yaml b/.gitea/workflows/gradle-test.yaml index ec9f1ec..2c4c1c7 100644 --- a/.gitea/workflows/gradle-test.yaml +++ b/.gitea/workflows/gradle-test.yaml @@ -43,7 +43,5 @@ jobs: uses: dorny/test-reporter@v1 with: name: Test Results - path: | - lib/build/test-results/test/*.xml - wrapper/javacord/build/test-results/test/*.xml + path: 'lib/build/test-results/test/*.xml,wrapper/javacord/build/test-results/test/*.xml' reporter: java-junit \ No newline at end of file -- 2.45.2 From 4d20dd65f217e05dedcac087676e9b50c870f392 Mon Sep 17 00:00:00 2001 From: tueem Date: Fri, 15 Nov 2024 11:46:58 +0100 Subject: [PATCH 10/10] upload test results instead of non working publishing --- .gitea/workflows/gradle-test.yaml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.gitea/workflows/gradle-test.yaml b/.gitea/workflows/gradle-test.yaml index 2c4c1c7..62fe064 100644 --- a/.gitea/workflows/gradle-test.yaml +++ b/.gitea/workflows/gradle-test.yaml @@ -38,10 +38,16 @@ jobs: DISCORD_TEST_TOKEN: ${{ secrets.DISCORD_TOKEN }} run: chmod +x gradlew; ./gradlew test - - name: Publish Test Results + - name: Move Test Results + if: always() + run: | + mkdir test-results/; + [ -d lib/build/test-results/test/ ] && mv lib/build/test-results/test/*.xml test-results/; + [ -d wrapper/javacord/build/test-results/test/ ] && mv wrapper/javacord/build/test-results/test/*.xml test-results/; + + - name: Upload Test Result + uses: christopherhx/gitea-upload-artifact@v4 if: always() - uses: dorny/test-reporter@v1 with: - name: Test Results - path: 'lib/build/test-results/test/*.xml,wrapper/javacord/build/test-results/test/*.xml' - reporter: java-junit \ No newline at end of file + name: test-results + path: test-results/ \ No newline at end of file -- 2.45.2