-
-
Notifications
You must be signed in to change notification settings - Fork 36
82 lines (82 loc) · 3.5 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
name: Build
on:
push:
branches: "**"
tags-ignore: [ "**" ]
pull_request:
release:
types: [ released ]
jobs:
build:
# Only run on PRs if the source branch is on someone else's repo
if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }}
runs-on: ubuntu-latest
steps:
- name: "checkout git repository"
uses: actions/checkout@v4
- name: "validate gradle wrapper"
uses: gradle/actions/wrapper-validation@v3
- name: "setup jdk"
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 21
- name: "setup gradle"
uses: gradle/actions/setup-gradle@v3
# gradle-build-action doesn't support caching files in the project dir
- name: "cache project local caches"
uses: actions/cache@v4
with:
path: |
.gradle/caches/VanillaGradle
.gradle/loom-cache
paper/.gradle/caches/paperweight
key: ${{ runner.os }}-project-local-gradle-caches-${{ hashFiles('**/libs.versions.toml', '**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-project-local-gradle-caches-
- name: "execute gradle build"
run: ./gradlew build
- name: "determine status"
run: |
if [ "$(./gradlew properties | awk '/^version:/ { print $2; }' | grep '\-SNAPSHOT')" ]; then
echo "STATUS=snapshot" >> $GITHUB_ENV
else
echo "STATUS=release" >> $GITHUB_ENV
fi
- name: "publish snapshot to sonatype snapshots"
if: "${{ env.STATUS != 'release' && github.event_name == 'push' && github.ref == 'refs/heads/master' }}"
run: ./gradlew publish
env:
ORG_GRADLE_PROJECT_sonatypeUsername: "${{ secrets.SONATYPE_USERNAME }}"
ORG_GRADLE_PROJECT_sonatypePassword: "${{ secrets.SONATYPE_PASSWORD }}"
- name: "publish release to maven central"
if: "${{ env.STATUS == 'release' && github.event_name == 'release' }}"
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
env:
ORG_GRADLE_PROJECT_sonatypeUsername: "${{ secrets.SONATYPE_USERNAME }}"
ORG_GRADLE_PROJECT_sonatypePassword: "${{ secrets.SONATYPE_PASSWORD }}"
ORG_GRADLE_PROJECT_signingKey: "${{ secrets.SIGNING_KEY }}"
ORG_GRADLE_PROJECT_signingPassword: "${{ secrets.SIGNING_PASSWORD }}"
- name: "publish release to modrinth"
if: "${{ env.STATUS == 'release' && github.event_name == 'release' }}"
run: ./gradlew publishModrinth
env:
MODRINTH_TOKEN: "${{ secrets.MODRINTH_TOKEN }}"
RELEASE_NOTES: "${{ github.event.release.body }}"
- name: "publish release to hangar"
if: "${{ env.STATUS == 'release' && github.event_name == 'release' }}"
run: ./gradlew publishAllPublicationsToHangar
env:
HANGAR_UPLOAD_KEY: "${{ secrets.HANGAR_UPLOAD_KEY }}"
RELEASE_NOTES: "${{ github.event.release.body }}"
- name: "publish release to ore"
if: "${{ env.STATUS == 'release' && github.event_name == 'release' }}"
run: ./gradlew publishDefaultPublicationToOre
env:
ORE_TOKEN: "${{ secrets.ORE_TOKEN }}"
RELEASE_NOTES: "${{ github.event.release.body }}"
- name: "upload artifacts"
uses: actions/upload-artifact@v4
with:
name: artifacts
path: "build/libs/*.jar"