-
-
Notifications
You must be signed in to change notification settings - Fork 31
246 lines (245 loc) · 10.3 KB
/
Copy pathpublish-release.yml
File metadata and controls
246 lines (245 loc) · 10.3 KB
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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
name: publish-release
on:
workflow_dispatch:
inputs:
forge:
description: 'Forge'
required: true
type: boolean
default: true
fabric:
description: 'Fabric'
required: true
type: boolean
default: true
neoforge:
description: 'NeoForge'
required: true
type: boolean
default: true
maven:
description: 'Maven'
required: true
type: boolean
default: true
modrinth:
description: 'Modrinth'
required: true
type: boolean
default: true
curseforge:
description: 'CurseForge'
required: true
type: boolean
default: true
jobs:
verify-resources:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Validate gradle wrapper
uses: gradle/actions/wrapper-validation@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e
- name: Setup JDK
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654
with:
java-version: 25
distribution: temurin
- name: Make gradle wrapper executable
run: chmod +x ./gradlew
- name: Run data generation
run: ./gradlew :fabric:runData
- name: Check for uncommitted datagen changes
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "::error::Generated resources are out of date. Please run data generation and commit the changes."
git diff
exit 1
fi
- name: Validate en_us.json file
uses: TwelveIterations/validate-minecraft-lang@0fc8683f070a73c13015b3e17a2130baa9e89d82
create-release:
runs-on: ubuntu-latest
environment: Releases
needs: verify-resources
outputs:
ref: v${{ steps.bump-version.outputs.version }}
version: ${{ steps.bump-version.outputs.version }}
build-matrix: ${{ steps.set-build-matrix.outputs.result }}
publish-matrix: ${{ steps.set-publish-matrix.outputs.result }}
steps:
- uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3
id: app-token
with:
app-id: ${{ vars.AUTOMATIONS_APP_ID }}
private-key: ${{ secrets.AUTOMATIONS_PRIVATE_KEY }}
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
token: ${{ steps.app-token.outputs.token }}
- name: Get GitHub App User ID
id: get-user-id
run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
- run: |
git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]'
git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com'
- name: Extracting version from properties
shell: bash
run: echo "version=$(cat gradle.properties | grep -w "\bversion\s*=" | cut -d= -f2)" >> $GITHUB_OUTPUT
id: extract-version
- name: Bumping version
uses: TwelveIterations/bump-version@86901cde5897b550e2e98fbe8962afc401c23c8f
with:
version: ${{ steps.extract-version.outputs.version }}
bump: revision
id: bump-version
- name: Updating version properties
run: |
sed -i "s/^\s*version\s*=.*/version = ${{ steps.bump-version.outputs.version }}/g" gradle.properties
git commit -am "Set version to ${{ steps.bump-version.outputs.version }}"
git push origin ${BRANCH_NAME}
git tag -a "v${{ steps.bump-version.outputs.version }}" -m "Release ${{ steps.bump-version.outputs.version }}"
git push origin "v${{ steps.bump-version.outputs.version }}"
shell: bash
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
- name: Preparing build matrix
id: set-build-matrix
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3
with:
script: |
const fs = require('fs');
const gradleProperties = fs.readFileSync('gradle.properties', 'utf8');
const includeFabric = gradleProperties.match(/^(?!#)include_fabric\s*=\s*true/m) && ${{inputs.fabric}};
const includeForge = gradleProperties.match(/^(?!#)include_forge\s*=\s*true/m) && ${{inputs.forge}};
const includeNeoForge = gradleProperties.match(/^(?!#)include_neoforge\s*=\s*true/m) && ${{inputs.neoforge}};
return {
loader: [includeFabric ? 'fabric' : false, includeForge ? 'forge' : false, includeNeoForge ? 'neoforge' : false].filter(Boolean),
}
- name: Preparing publish matrix
id: set-publish-matrix
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3
with:
script: |
const fs = require('fs');
const gradleProperties = fs.readFileSync('gradle.properties', 'utf8');
const includeFabric = gradleProperties.match(/^(?!#)include_fabric\s*=\s*true/m) && ${{inputs.fabric}};
const includeForge = gradleProperties.match(/^(?!#)include_forge\s*=\s*true/m) && ${{inputs.forge}};
const includeNeoForge = gradleProperties.match(/^(?!#)include_neoforge\s*=\s*true/m) && ${{inputs.neoforge}};
const curseForgeProjectId = gradleProperties.match(/^(?!#)curseforge_project_id\s*=\s*(.+)/m);
const modrinthProjectId = gradleProperties.match(/^(?!#)modrinth_project_id\s*=\s*(.+)/m);
const mavenReleases = gradleProperties.match(/^(?!#)maven_releases\s*=\s*(.+)/m);
const publishCurseForge = curseForgeProjectId && ${{inputs.curseforge}};
const publishModrinth = modrinthProjectId && ${{inputs.modrinth}};
const publishMaven = mavenReleases && ${{inputs.maven}};
return {
loader: ['common', includeFabric ? 'fabric' : false, includeForge ? 'forge' : false, includeNeoForge ? 'neoforge' : false].filter(Boolean),
site: [publishCurseForge ? 'curseforge' : false, publishModrinth ? 'modrinth' : false, publishMaven ? 'publish' : false].filter(Boolean),
exclude: [
{loader: 'common', site: 'curseforge'},
{loader: 'common', site: 'modrinth'}
]
}
build-common:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
ref: ${{ needs.create-release.outputs.ref }}
- name: Validate gradle wrapper
uses: gradle/actions/wrapper-validation@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e
- name: Setup JDK
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654
with:
java-version: 25
distribution: temurin
cache: 'gradle'
- name: Make gradle wrapper executable
run: chmod +x ./gradlew
- name: Build common artifact
run: ./gradlew :common:build '-Pversion=${{needs.create-release.outputs.version}}'
- name: Upload common artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
with:
name: common-artifact
path: common/build
needs: create-release
build-release:
runs-on: ubuntu-latest
strategy:
matrix: ${{fromJson(needs.create-release.outputs.build-matrix)}}
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
ref: ${{ needs.create-release.outputs.ref }}
- name: Validate gradle wrapper
uses: gradle/actions/wrapper-validation@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e
- name: Setup JDK
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654
with:
java-version: 25
distribution: temurin
cache: 'gradle'
- name: Make gradle wrapper executable
run: chmod +x ./gradlew
- name: Download common artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c
with:
name: common-artifact
path: common/build
- name: Workaround for FG7
run: ./gradlew
if: matrix.loader == 'forge'
- name: Build ${{ matrix.loader }} artifact
run: ./gradlew :${{ matrix.loader }}:build '-Pversion=${{needs.create-release.outputs.version}}'
- name: Upload ${{ matrix.loader }} artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
with:
name: ${{ matrix.loader }}-artifact
path: ${{ matrix.loader }}/build
needs:
- create-release
- build-common
publish-release:
runs-on: ubuntu-latest
environment: Releases
strategy:
matrix: ${{fromJson(needs.create-release.outputs.publish-matrix)}}
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
ref: ${{ needs.create-release.outputs.ref }}
- name: Download ${{ matrix.loader }} artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c
with:
name: ${{ matrix.loader }}-artifact
path: ${{ matrix.loader }}/build
- name: Validate gradle wrapper
uses: gradle/actions/wrapper-validation@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e
- name: Setup JDK
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654
with:
java-version: 25
distribution: temurin
cache: 'gradle'
- name: Make gradle wrapper executable
run: chmod +x ./gradlew
- name: Workaround for FG7
run: ./gradlew
if: matrix.loader == 'forge'
- name: Publish
run: ./gradlew :${{ matrix.loader }}:${{ matrix.site }} '-Pversion=${{needs.create-release.outputs.version}}' '-PmavenUsername=${{ secrets.MAVEN_USER }}' '-PmavenPassword=${{ secrets.MAVEN_PASSWORD }}'
env:
CURSEFORGE_TOKEN: ${{secrets.CURSEFORGE_TOKEN}}
MODRINTH_TOKEN: ${{secrets.MODRINTH_TOKEN}}
needs:
- create-release
- build-common
- build-release