From 2dc74b6e86d41b74b6e44a62bdd05614854d3d58 Mon Sep 17 00:00:00 2001 From: HappyAreaBean Date: Mon, 15 Apr 2024 14:53:17 +0800 Subject: [PATCH 1/4] build: implement github actions --- .github/workflows/dev-jar.yml | 30 ++++++++++++++++++++++++++++++ build.gradle | 16 ++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 .github/workflows/dev-jar.yml diff --git a/.github/workflows/dev-jar.yml b/.github/workflows/dev-jar.yml new file mode 100644 index 0000000..fcdefe9 --- /dev/null +++ b/.github/workflows/dev-jar.yml @@ -0,0 +1,30 @@ +name: Build DEV Jars + +on: [push, pull_request] + +jobs: + build_dev_jars: + name: Build DEV jars + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Setup JDK + uses: actions/setup-java@v2 + with: + distribution: 'adopt' + java-version: '8' + - name: Build with Gradle + run: | + ./gradlew jar snapshotVersion + git_hash=$(git rev-parse --short "$GITHUB_SHA") + echo "git_hash=$git_hash" >> $GITHUB_ENV + echo "snapshotVersion=$(cat build/versions/snapshot.txt)" >> $GITHUB_ENV + echo "artifactPath=$(pwd)/build/libs" >> $GITHUB_ENV + - name: Upload Plugin jar + uses: actions/upload-artifact@v3 + with: + name: SimpleJoinMessage-${{ env.snapshotVersion }}-${{ env.git_hash }}.jar + path: ${{ env.artifactPath }}/SimpleJoinMessage-${{ env.snapshotVersion }}.jar \ No newline at end of file diff --git a/build.gradle b/build.gradle index 50fdb70..f335937 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,5 @@ +import java.nio.file.Files + plugins { id 'com.github.johnrengelman.shadow' version '7.1.2' id 'kr.entree.spigradle' version '2.4.2' @@ -131,3 +133,17 @@ tasks { relocate("kotlin", "${libsPackage}.kotlin") } } + +abstract class PrintSnapshotVersionTask extends DefaultTask { + @TaskAction + def print() { + File versionsDir = project.file("$project.buildDir/versions") + File textFile = project.file("$project.buildDir/versions/snapshot.txt") + versionsDir.mkdirs() + Files.deleteIfExists(textFile.toPath()) + textFile.createNewFile() + textFile << "$project.version" + } +} + +tasks.register('snapshotVersion', PrintSnapshotVersionTask) From 15ae7bb428a1348e0f60c74c7fadf80734ee4cc8 Mon Sep 17 00:00:00 2001 From: HappyAreaBean Date: Mon, 15 Apr 2024 14:56:26 +0800 Subject: [PATCH 2/4] build: make gradlew executable --- .github/workflows/dev-jar.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/dev-jar.yml b/.github/workflows/dev-jar.yml index fcdefe9..cfe1226 100644 --- a/.github/workflows/dev-jar.yml +++ b/.github/workflows/dev-jar.yml @@ -16,6 +16,8 @@ jobs: with: distribution: 'adopt' java-version: '8' + - name: Make gradlew executable + run: chmod +x ./gradlew - name: Build with Gradle run: | ./gradlew jar snapshotVersion From b448a734130d45c85c28f53d735d689a72351e3a Mon Sep 17 00:00:00 2001 From: HappyAreaBean Date: Mon, 15 Apr 2024 14:59:02 +0800 Subject: [PATCH 3/4] build: add missing maven repo for configlib --- build.gradle | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build.gradle b/build.gradle index f335937..449e477 100644 --- a/build.gradle +++ b/build.gradle @@ -41,6 +41,10 @@ repositories { url = "https://s01.oss.sonatype.org/content/repositories/snapshots/" } + maven { + url = "https://repo.fantasyrealms.net/releases" + } + maven { url 'https://jitpack.io' } //Add your repositories here From 38f6820bfac08876d647c3815a4de0d333cbce28 Mon Sep 17 00:00:00 2001 From: HappyAreaBean Date: Mon, 15 Apr 2024 15:01:39 +0800 Subject: [PATCH 4/4] build: replace gradlew task to shadowJar --- .github/workflows/dev-jar.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dev-jar.yml b/.github/workflows/dev-jar.yml index cfe1226..5bac521 100644 --- a/.github/workflows/dev-jar.yml +++ b/.github/workflows/dev-jar.yml @@ -20,7 +20,7 @@ jobs: run: chmod +x ./gradlew - name: Build with Gradle run: | - ./gradlew jar snapshotVersion + ./gradlew shadowJar snapshotVersion git_hash=$(git rev-parse --short "$GITHUB_SHA") echo "git_hash=$git_hash" >> $GITHUB_ENV echo "snapshotVersion=$(cat build/versions/snapshot.txt)" >> $GITHUB_ENV