-
-
Notifications
You must be signed in to change notification settings - Fork 8
212 lines (206 loc) · 7.71 KB
/
check.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
name: Check
run-name: Check ${{ inputs.version }}
permissions:
contents: write
on:
workflow_call:
inputs:
branch:
required: false
type: string
version:
required: true
type: string
push_changed:
default: true
required: false
type: boolean
publish:
default: true
required: false
type: boolean
publish_prs:
default: false
required: false
type: boolean
secrets:
MAVEN_USER:
required: false
MAVEN_PASSWORD:
required: false
DISCORD_WEBHOOK:
required: false
workflow_dispatch:
inputs:
version:
description: 'Version'
required: true
push_changed:
description: 'Push changed patches'
default: true
required: false
type: boolean
publish:
description: 'Publish'
default: true
required: false
type: boolean
jobs:
common:
runs-on: ubuntu-latest
outputs:
discord_fields: ${{ steps.discord_fields.outputs.discord_fields }}
test_versions: ${{ steps.test_versions.outputs.test_versions }}
version_type: ${{ fromJson(steps.split_version.outputs.result).version_type }}
version_name: ${{ fromJson(steps.split_version.outputs.result).version_name }}
steps:
- uses: actions/github-script@v7
id: split_version
env:
VERSION: ${{ inputs.version }}
with:
script: |
const version = process.env.VERSION.split("/");
var returnValue = {version_name: version[version.length - 1], version_type: version[0]}
return returnValue;
- name: Create discord fields json
if: ${{ inputs.publish }}
id: discord_fields
run: |
echo "discord_fields<<EOF" >> $GITHUB_OUTPUT
jq -n '[
{
"name": "Minecraft Version",
"value": $ENV.MC_VERSION,
"inline": true
}
]' >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
env:
MC_VERSION: ${{ fromJson(steps.split_version.outputs.result).version_name }}
- name: Notify discord of start
if: ${{ inputs.publish }}
uses: neoforged/action-webhooks@v1
with:
webhook_url: ${{ secrets.DISCORD_WEBHOOK }}
status: started
include_commit_message: 'false'
fields: ${{ steps.discord_fields.outputs.discord_fields }}
- uses: actions/checkout@v4
with:
ref: ${{ inputs.branch || github.ref }}
- run: |
git config --global user.name github-actions
git config --global user.email 41898282+github-actions[bot]@users.noreply.github.com
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
cache-read-only: false
env:
GRADLE_BUILD_ACTION_CACHE_KEY_JOB_INSTANCE: check
GRADLE_BUILD_ACTION_CACHE_KEY_JOB_EXECUTION: ${{ github.run_id }}-${{ github.run_attempt }}
- name: Apply and Create patches
env:
VERSION_NAME: ${{ fromJson(steps.split_version.outputs.result).version_name }}
VERSION_TYPE: ${{ fromJson(steps.split_version.outputs.result).version_type }}
run: ./gradlew :$VERSION_NAME:projectApplyAll :$VERSION_NAME:projectMakeAll -Ptype=$VERSION_TYPE
- name: Check if patches have changed
id: check_changes
if: ${{ inputs.push_changed }}
run: |
git add .
git diff-index --quiet HEAD || git commit -m "Update patches" && git push
- name: Make Zip
env:
VERSION_NAME: ${{ fromJson(steps.split_version.outputs.result).version_name }}
VERSION_TYPE: ${{ fromJson(steps.split_version.outputs.result).version_type }}
if: ${{ always() }}
run: ./gradlew :$VERSION_NAME:makeZip -Ptype=$VERSION_TYPE
- name: Upload Zip as Artifact
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: neoform-${{ fromJson(steps.split_version.outputs.result).version_name }}
path: build/distributions/*.zip
# This creates a "maven-publish" artifact that contains the results of a locally run publish task
# This artifact is picked up by the "publish-prs.yml" workflow for PRs and published to a temporary maven repository
- name: Publish artifacts for PR Publication
uses: neoforged/action-pr-publishing/upload@v1
if: ${{ inputs.publish_prs }}
with:
publishing-task: ":${{ fromJson(steps.split_version.outputs.result).version_name }}:publishAllPublicationsTo_githubPackages_PRsRepository -Ptype=${{ fromJson(steps.split_version.outputs.result).version_type }}"
- name: Get Java Test Versions
id: test_versions
env:
VERSION: ${{ inputs.version }}
NEXT_JDK_VERSION: ${{ vars.NEXT_JDK_VERSION }}
run: echo "test_versions=$(cat versions/$VERSION/config.json | jq -c '[range(.java_target; $ENV.NEXT_JDK_VERSION | tonumber)]')" >> "$GITHUB_OUTPUT"
testjdks:
name: Test Jdks on side ${{ matrix.side }} using mappings ${{ matrix.mappings }} using java version ${{ matrix.jdk_version }}
runs-on: ubuntu-latest
needs: common
strategy:
fail-fast: false
matrix:
jdk_version: ${{ fromJson(needs.common.outputs.test_versions) }}
mappings: [HotSpot]
side: [Client, Joined, Server]
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.branch || github.ref }}
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
cache-read-only: true
env:
GRADLE_BUILD_ACTION_CACHE_KEY_JOB_INSTANCE: check
GRADLE_BUILD_ACTION_CACHE_KEY_JOB_EXECUTION: ${{ github.run_id }}-${{ github.run_attempt }}
- name: Test jdk
env:
VERSION_NAME: ${{ needs.common.outputs.version_name }}
SIDE: ${{ matrix.side }}
MAPPINGS: ${{ matrix.mappings }}
JDK_VERSION: ${{ matrix.jdk_version }}
VERSION_TYPE: ${{ needs.common.outputs.version_type }}
run: ./gradlew :$VERSION_NAME:testCompile$SIDE$MAPPINGS$JDK_VERSION :$VERSION_NAME:testDecompile$SIDE$MAPPINGS${JDK_VERSION}Compare -Ptype=$VERSION_TYPE
publish:
name: Publish to maven
runs-on: ubuntu-latest
needs: [common, testjdks]
outputs:
timestamp: ${{ env.GRADLE_TIMESTAMP }}
if: ${{ inputs.publish }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.branch || github.ref }}
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
cache-read-only: false
env:
GRADLE_BUILD_ACTION_CACHE_KEY_JOB_INSTANCE: check
- name: Publish
env:
VERSION_NAME: ${{ needs.common.outputs.version_name }}
VERSION_TYPE: ${{ needs.common.outputs.version_type }}
ORG_GRADLE_PROJECT_MAVEN_URL: ${{ vars.MAVEN_URL }}
ORG_GRADLE_PROJECT_MAVEN_USER: ${{ secrets.MAVEN_USER }}
ORG_GRADLE_PROJECT_MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
run: ./gradlew getTimestamp :$VERSION_NAME:publish -Ptype=$VERSION_TYPE
discord:
name: Send status to discord
runs-on: ubuntu-latest
needs: [common, testjdks, publish]
if: ${{ always() && inputs.publish }}
steps:
- name: Notify discord of finish
if: ${{ inputs.publish }}
uses: neoforged/action-webhooks@v1
with:
webhook_url: ${{ secrets.DISCORD_WEBHOOK }}
status: ${{ needs.common.result == 'success' && needs.testjdks.result == 'success' && needs.publish.result || needs.common.result == 'success' && needs.testjdks.result || needs.common.result }}
include_commit_message: 'false'
version: ${{ needs.publish.result == 'success' && format('{0}-{1}', needs.common.outputs.version_name, needs.publish.outputs.timestamp) || '?' }}
fields: ${{ needs.common.outputs.discord_fields }}