|
1 | | -name: Java CI |
| 1 | +name: Gradle CI |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | workflow_dispatch: |
5 | 5 | push: |
6 | 6 | pull_request: |
| 7 | + release: |
| 8 | + types: [created, prereleased] |
7 | 9 |
|
8 | 10 | jobs: |
9 | | - # Build Movecraft-CoreProtect |
10 | 11 | build: |
11 | 12 | runs-on: ubuntu-latest |
12 | 13 | permissions: |
13 | 14 | contents: read |
| 15 | + packages: write |
14 | 16 |
|
15 | 17 | steps: |
16 | | - - name: Checkout Movecraft-CoreProtect |
17 | | - uses: actions/checkout@v4 |
18 | | - - name: Set up JDK 21 |
19 | | - uses: actions/setup-java@v4 |
20 | | - with: |
21 | | - distribution: 'temurin' |
22 | | - java-version: '21' |
23 | | - - name: Setup Gradle |
24 | | - uses: gradle/actions/setup-gradle@v3 |
25 | | - with: |
26 | | - build-scan-publish: true |
27 | | - build-scan-terms-of-use-url: "https://gradle.com/terms-of-service" |
28 | | - build-scan-terms-of-use-agree: "yes" |
| 18 | + - name: Checkout Movecraft-CoreProtect |
| 19 | + uses: actions/checkout@v4 |
| 20 | + - name: Set up JDK 21 |
| 21 | + uses: actions/setup-java@v4 |
| 22 | + with: |
| 23 | + distribution: 'temurin' |
| 24 | + java-version: '21' |
| 25 | + - name: Setup Gradle |
| 26 | + uses: gradle/actions/setup-gradle@v3 |
| 27 | + with: |
| 28 | + build-scan-publish: true |
| 29 | + build-scan-terms-of-use-url: "https://gradle.com/terms-of-service" |
| 30 | + build-scan-terms-of-use-agree: "yes" |
29 | 31 |
|
30 | | - - name: Build with Gradle |
31 | | - run: ./gradlew clean build --parallel |
| 32 | + - name: Build with Gradle |
| 33 | + run: ./gradlew clean build --parallel |
32 | 34 |
|
33 | | - - name: Stage jar |
34 | | - run: mkdir staging && cp build/libs/Movecraft-CoreProtect.jar staging && mv staging/Movecraft-CoreProtect.jar staging/Movecraft-CoreProtect_$GITHUB_SHA.jar |
35 | | - - name: Upload jar |
36 | | - uses: actions/upload-artifact@v4 |
37 | | - with: |
38 | | - name: Movecraft-CoreProtect_Dev-Build |
39 | | - path: staging/Movecraft-CoreProtect_*.jar |
| 35 | + - name: Publish to GitHub Packages |
| 36 | + run: ./gradlew publish --parallel |
| 37 | + if: ${{ github.event_name == 'release' }} |
| 38 | + env: |
| 39 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 40 | + |
| 41 | + - name: Publish to PaperMC Hangar |
| 42 | + run: ./gradlew publishPluginPublicationToHangar --parallel |
| 43 | + if: ${{ github.event_name == 'release' }} |
| 44 | + env: |
| 45 | + HANGAR_API_TOKEN: ${{ secrets.HANGAR_API_TOKEN }} |
| 46 | + |
| 47 | + - name: Stage jar |
| 48 | + run: mkdir staging && cp build/libs/Movecraft-CoreProtect.jar staging && mv staging/Movecraft-CoreProtect.jar staging/Movecraft-CoreProtect_$GITHUB_SHA.jar |
| 49 | + - name: Upload jar |
| 50 | + uses: actions/upload-artifact@v4 |
| 51 | + with: |
| 52 | + name: Movecraft-CoreProtect_Dev-Build |
| 53 | + path: staging/Movecraft-CoreProtect_*.jar |
0 commit comments