-
-
Notifications
You must be signed in to change notification settings - Fork 6
112 lines (96 loc) · 3.24 KB
/
main.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
name: Test and Release
on:
push:
branches:
- 'main'
schedule:
# PaperMC doesn't change version numbers for latest releases meaning the build may break
# unexpectedly. Build every so often so that we know if a breaking change has been published
- cron: '0 0 * * 6'
concurrency:
group: ${{ format('{0}-{1}', github.workflow, github.ref) }}
cancel-in-progress: false
jobs:
test:
name: Run unit tests
strategy:
matrix:
os: [ ubuntu-latest, windows-latest ]
java: [ 21 ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Common Setup
uses: ./.github/actions/common-setup
with:
java-version: ${{ matrix.java }}
- name: Build with Gradle
run: ./gradlew build --info
- name: Upload build results
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }} Java ${{ matrix.java }} build results
path: ${{ github.workspace }}/build/libs/
- name: Upload test results
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }} Java ${{ matrix.java }} test results
path: ${{ github.workspace }}/build/reports/
release:
runs-on: ubuntu-latest
needs:
- test
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Common Setup
uses: ./.github/actions/common-setup
with:
java-version: 21
- name: Publish with Gradle
run: ./gradlew -Pver="0.0.0-RC-1" release
- name: Upload build results
uses: actions/upload-artifact@v4
with:
name: Release Build
path: ${{ github.workspace }}/build/libs/
notify:
name: Send job complete notification
runs-on: ubuntu-latest
needs:
- test
- release
if: always() && vars.DISCORD_WEBHOOK_ID
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Common Setup
uses: ./.github/actions/common-setup
with:
java-version: 21
- name: Retrieve Project Name
run: echo "PROJECT_NAME=$(${{github.workspace}}/gradlew -q printProjectName)" >> $GITHUB_ENV
- name: Notify on success
if: success()
uses: appleboy/[email protected]
with:
webhook_id: ${{ vars.DISCORD_WEBHOOK_ID }}
webhook_token: ${{ secrets.DISCORD_WEBHOOK_TOKEN }}
color: "#00FF00"
username: "${{ env.PROJECT_NAME }} Release Bot"
message: >
An ${{ env.PROJECT_NAME }} snapshot was deployed by ${{ github.actor }}:
https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
- name: Notify on failure
if: failure()
uses: appleboy/[email protected]
with:
webhook_id: ${{ vars.DISCORD_WEBHOOK_ID }}
webhook_token: ${{ secrets.DISCORD_WEBHOOK_TOKEN }}
color: "#FF0000"
username: "${{ env.PROJECT_NAME }} Release Bot"
message: >
An ${{ env.PROJECT_NAME }} snapshot deployment ran by ${{ github.actor }} failed:
https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}