-
Notifications
You must be signed in to change notification settings - Fork 0
250 lines (204 loc) · 8.18 KB
/
build.yml
File metadata and controls
250 lines (204 loc) · 8.18 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
247
248
249
250
name: "Project Build"
run-name: "[📦]: Project Build #${{ github.run_number }}"
on:
push:
branches:
- dev
paths:
- 'shaders/**'
- 'project.json'
- 'CHANGELOG.md'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
info:
name: "[🖥️] Project Info"
runs-on: ubuntu-latest
if: ${{ !github.event.repository.fork }}
outputs:
name: ${{ steps.check.outputs.name }}
version: ${{ steps.check.outputs.version }}
version_type: ${{ steps.check.outputs.version_type }}
full_name: ${{ steps.check.outputs.name }}-${{ steps.check.outputs.version }}
loaders: ${{ steps.check.outputs.loaders }}
game_versions: ${{ steps.check.outputs.game_versions }}
changelog: ${{ steps.changelog.outputs.description }}
included: ${{ steps.check.outputs.included }}
make_release: ${{ steps.check.outputs.make_release }}
steps:
- name: "[📦] Checkout"
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: "[🔍] Check required files and folders"
uses: andstor/file-existence-action@v3.0.0
with:
fail: true
ignore_case: true
files: "project.json, LICENSE, README.md, shaders"
- name: "[📥] Get Project Info"
id: project_info
uses: Xikaro/action-read-json@v1.1.1
with:
file_path: "project.json"
flat_arrays: true
- name: "[📖] Parse Changelog"
id: changelog
uses: coditory/changelog-parser@v1.0.2
continue-on-error: true
with:
path: "CHANGELOG.md"
- name: "[🔍] Check if tag exists"
id: tag_check
uses: mukunku/tag-exists-action@v1.7.0
with:
tag: ${{ steps.changelog.outputs.version }}
- name: "[🔍] Check"
id: check
shell: bash
run: |
# Get data from previous steps
CHANGELOG_VER="${{ steps.changelog.outputs.version }}"
TAG_EXISTS="${{ steps.tag_check.outputs.exists }}"
PROJECT_NAME="${{ steps.project_info.outputs.name }}"
# Preparation
RAW_INCLUDED="${{ steps.project_info.outputs.included }}"
INCLUDED=$(echo "$RAW_INCLUDED" | tr -d '[]"' | tr ',' ' ' | xargs)
RAW_LOADERS="${{ steps.project_info.outputs.targets_loaders }}"
LOADERS=$(echo "$RAW_LOADERS" | tr ' ' ',')
RAW_GAME_VERSIONS="${{ steps.project_info.outputs.targets_game_versions }}"
GAME_VERSIONS=$(echo "$RAW_GAME_VERSIONS" | tr ' ' ',')
IS_RELEASE_CANDIDATE="false"
if [[ "$TAG_EXISTS" == "false" && -n "$CHANGELOG_VER" && "$CHANGELOG_VER" != "Unreleased" ]]; then
IS_RELEASE_CANDIDATE="true"
fi
if [[ "$IS_RELEASE_CANDIDATE" == "true" ]]; then
PROJECT_VERSION="$CHANGELOG_VER"
PROJECT_VERSION_TYPE="${{ steps.project_info.outputs.version_type }}"
else
PROJECT_VERSION="${{ steps.project_info.outputs.version }}-build-${{ github.run_number }}"
PROJECT_VERSION_TYPE="Unreleased"
fi
# Save values for next steps
echo "game_versions=$GAME_VERSIONS" >> $GITHUB_OUTPUT
echo "loaders=$LOADERS" >> $GITHUB_OUTPUT
echo "name=$PROJECT_NAME" >> $GITHUB_OUTPUT
echo "version=$PROJECT_VERSION" >> $GITHUB_OUTPUT
echo "version_type=$PROJECT_VERSION_TYPE" >> $GITHUB_OUTPUT
echo "exists=$TAG_EXISTS" >> $GITHUB_OUTPUT
echo "make_release=$IS_RELEASE_CANDIDATE" >> $GITHUB_OUTPUT
echo "included=$INCLUDED" >> $GITHUB_OUTPUT
- name: "[📝] Generate Build Summary"
uses: WcAServices/markdown-template-action@v1.1.1
with:
template: |
## 📊 Build Information
### Project Info
| Parameter | Value |
|-----------|-------|
| 📃 **Name** | `${{ steps.check.outputs.name }}` |
| 📃 **Version** | `${{ steps.check.outputs.version }}` |
| 📃 **Release Type** | `${{ steps.check.outputs.version_type }}` |
| 📃 **Game Versions** | `${{ steps.check.outputs.game_versions }}` |
| 📃 **Loaders** | `${{ steps.check.outputs.loaders }}` |
### Build Decision
| Parameter | Value |
|-----------|-------|
| 📃 **Tag Exists** | `${{ steps.check.outputs.exists }}` |
| 📃 **Make Release** | `${{ steps.check.outputs.make_release }}` |
build:
name: "[📦] Build Project"
needs: [info]
runs-on: ubuntu-latest
steps:
- name: "[📦] Checkout"
uses: actions/checkout@v6
- name: "[🔄] Replace"
shell: bash
run: |
set +e
VERSION=${{ needs.info.outputs.version }}
sed -i -e "s/DEV/${VERSION}/g" project.json
sed -i -e "s/DEV/${VERSION}/g" shaders/pack.json
- name: "[📁] Prepare artifact"
uses: vimtor/action-zip@v1.3
with:
files: ${{ needs.info.outputs.included }}
dest: "${{ needs.info.outputs.name }}-${{ needs.info.outputs.version }}.zip"
recursive: false
- name: "[🚀] Upload artifact"
uses: actions/upload-artifact@v7
with:
name: "${{ needs.info.outputs.name }}-${{ needs.info.outputs.version }}"
path: "${{ needs.info.outputs.name }}-${{ needs.info.outputs.version }}.zip"
if-no-files-found: error
release:
name: "[🚀] Release"
needs: [info, build]
runs-on: ubuntu-latest
if: ${{ needs.info.outputs.make_release == true }}
steps:
- name: "[📦] Download artifact"
uses: actions/download-artifact@v8
- name: "[🔒] Verify"
shell: bash
run: |
echo "=== Token Verification ==="
if [ -z "${{ secrets.MODRINTH_TOKEN }}" ]; then
echo "::error::MODRINTH_TOKEN not found"
exit 1
fi
echo "✅ MODRINTH_TOKEN: OK"
if [ -z "${{ secrets.CURSEFORGE_TOKEN }}" ]; then
echo "::error::CURSEFORGE_TOKEN not found"
exit 1
fi
echo "✅ CURSEFORGE_TOKEN: OK"
echo ""
echo "=== ID Verification ==="
if [ -z "${{ vars.MODRINTH_ID }}" ]; then
echo "::error::MODRINTH_ID not found"
exit 1
fi
echo "✅ MODRINTH_ID: OK"
if [ -z "${{ vars.CURSEFORGE_ID }}" ]; then
echo "::error::CURSEFORGE_ID not found"
exit 1
fi
echo "✅ CURSEFORGE_ID: OK"
echo ""
echo "=== Artifact Verification ==="
if [ ! -f "${{ needs.info.outputs.full_name }}.zip" ]; then
echo "::error::Artifact not found"
ls -la
exit 1
fi
echo "✅ Artifact: OK"
echo ""
- name: "[🚀] Release"
if: ${{ vars.ACTIONS_STEP_DEBUG != 'true' }}
uses: Xikaro/game-publish@3.3.3
with:
modrinth-id: ${{ vars.MODRINTH_ID }}
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
curseforge-id: ${{ vars.CURSEFORGE_ID }}
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
github-name: ${{ needs.info.outputs.version }}
github-tag: ${{ needs.info.outputs.version }}
github-generate-changelog: true
github-draft: false
github-prerelease: ${{ needs.info.outputs.version_type != 'release' }}
github-token: ${{ secrets.GITHUB_TOKEN }}
files: ${{ needs.info.outputs.full_name }}.zip
name: ${{ needs.info.outputs.full_name }}
version: ${{ needs.info.outputs.version }}
version-type: ${{ needs.info.outputs.version_type }}
changelog: ${{ needs.info.outputs.changelog }}
loaders: ${{ needs.info.outputs.loaders }}
game-versions: ${{ needs.info.outputs.game_versions }}
game-version-filter: none
retry-attempts: 2
retry-delay: 10000
fail-mode: fail