Skip to content

Commit

Permalink
Merge pull request #2 from HappyAreaBean/build/github-actions
Browse files Browse the repository at this point in the history
build: GitHub actions
  • Loading branch information
HappyAreaBean authored Apr 15, 2024
2 parents 93d8c88 + 38f6820 commit 97314fd
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/dev-jar.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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: Make gradlew executable
run: chmod +x ./gradlew
- name: Build with Gradle
run: |
./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
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
20 changes: 20 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -39,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
Expand Down Expand Up @@ -131,3 +137,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)

0 comments on commit 97314fd

Please sign in to comment.