Skip to content

Commit 97314fd

Browse files
Merge pull request #2 from HappyAreaBean/build/github-actions
build: GitHub actions
2 parents 93d8c88 + 38f6820 commit 97314fd

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

.github/workflows/dev-jar.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Build DEV Jars
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build_dev_jars:
7+
name: Build DEV jars
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v2
12+
with:
13+
fetch-depth: 0
14+
- name: Setup JDK
15+
uses: actions/setup-java@v2
16+
with:
17+
distribution: 'adopt'
18+
java-version: '8'
19+
- name: Make gradlew executable
20+
run: chmod +x ./gradlew
21+
- name: Build with Gradle
22+
run: |
23+
./gradlew shadowJar snapshotVersion
24+
git_hash=$(git rev-parse --short "$GITHUB_SHA")
25+
echo "git_hash=$git_hash" >> $GITHUB_ENV
26+
echo "snapshotVersion=$(cat build/versions/snapshot.txt)" >> $GITHUB_ENV
27+
echo "artifactPath=$(pwd)/build/libs" >> $GITHUB_ENV
28+
- name: Upload Plugin jar
29+
uses: actions/upload-artifact@v3
30+
with:
31+
name: SimpleJoinMessage-${{ env.snapshotVersion }}-${{ env.git_hash }}.jar
32+
path: ${{ env.artifactPath }}/SimpleJoinMessage-${{ env.snapshotVersion }}.jar

build.gradle

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import java.nio.file.Files
2+
13
plugins {
24
id 'com.github.johnrengelman.shadow' version '7.1.2'
35
id 'kr.entree.spigradle' version '2.4.2'
@@ -39,6 +41,10 @@ repositories {
3941
url = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
4042
}
4143

44+
maven {
45+
url = "https://repo.fantasyrealms.net/releases"
46+
}
47+
4248
maven { url 'https://jitpack.io' }
4349

4450
//Add your repositories here
@@ -131,3 +137,17 @@ tasks {
131137
relocate("kotlin", "${libsPackage}.kotlin")
132138
}
133139
}
140+
141+
abstract class PrintSnapshotVersionTask extends DefaultTask {
142+
@TaskAction
143+
def print() {
144+
File versionsDir = project.file("$project.buildDir/versions")
145+
File textFile = project.file("$project.buildDir/versions/snapshot.txt")
146+
versionsDir.mkdirs()
147+
Files.deleteIfExists(textFile.toPath())
148+
textFile.createNewFile()
149+
textFile << "$project.version"
150+
}
151+
}
152+
153+
tasks.register('snapshotVersion', PrintSnapshotVersionTask)

0 commit comments

Comments
 (0)