-
Notifications
You must be signed in to change notification settings - Fork 3
253 lines (220 loc) · 8.84 KB
/
build.yaml
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
251
252
253
name: build
on:
push:
branches:
- '*'
tags:
- v*.*.*
- v*.*.*-rc.*
pull_request:
permissions:
contents: write
env:
target-name: hackpack
jobs:
build-artifacts:
name: Build modpack
runs-on: ubuntu-22.04
steps:
- name: Fetch Repo
uses: actions/checkout@v3
with:
fetch-depth: 0 # checkout non-detached, so git describe works
- name: get go for packwiz
uses: actions/setup-go@v4
with:
go-version: "1.20"
cache: false # only caches go projects, not general go pkgs
- name: get go cache env
id: go-cache-env
run: |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "GOMODCACHE<<$EOF" >> $GITHUB_ENV
go env GOMODCACHE >> $GITHUB_ENV
echo "$EOF" >> $GITHUB_ENV
echo "GOCACHE<<$EOF" >> $GITHUB_ENV
go env GOCACHE >> $GITHUB_ENV
echo "$EOF" >> $GITHUB_ENV
- name: cache go
uses: actions/cache@v3
with:
path: |
${{env.GOMODCACHE}}
${{env.GOCACHE}}
key: ${{ runner.os }}-gomod
- name: install packwiz
run: go install github.com/packwiz/packwiz@latest
- name: install dasel
run: go install github.com/tomwright/dasel/v2/cmd/dasel@v2.2.0
- name: get base version number
id: find_version
run: echo "NEW_VERSION=$(git describe --always --tags)" >> $GITHUB_OUTPUT
- name: Set new version number (default branch / tagged build)
if: ((github.ref == format('refs/heads/{0}', github.event.repository.default_branch)) || (startsWith(github.ref, 'refs/tags/')))
run: |
SET_VERSION="${{steps.find_version.outputs.NEW_VERSION}}"
sed -i "s~version = \"dev\"~version = \"$SET_VERSION\"~g" pack.toml
echo "SET_VERSION=${SET_VERSION}" >> $GITHUB_ENV
- name: Set new version number (PR)
if: ((github.ref != format('refs/heads/{0}', github.event.repository.default_branch)) && (github.event_name == 'pull_request'))
run: |
SET_VERSION="${{steps.find_version.outputs.NEW_VERSION}}+PR$(echo "${{ github.ref_name }}" | sed "s~/merge~~g")"
sed -i "s~version = \"dev\"~version = \"$SET_VERSION\"~g" pack.toml
echo "SET_VERSION=${SET_VERSION}" >> $GITHUB_ENV
- name: Set new version number (Other branch)
if: ((github.ref != format('refs/heads/{0}', github.event.repository.default_branch)) && (github.event_name != 'pull_request') && !(startsWith(github.ref, 'refs/tags/')))
run: |
SET_VERSION="${{steps.find_version.outputs.NEW_VERSION}}+${{ github.ref_name }}"
sed -i "s~version = \"dev\"~version = \"$SET_VERSION\"~g" pack.toml
echo "SET_VERSION=${SET_VERSION}" >> $GITHUB_ENV
- run: |
echo "# Version" >> $GITHUB_STEP_SUMMARY
echo "${{env.SET_VERSION}}" >> $GITHUB_STEP_SUMMARY
- name: generate hashes
run: packwiz refresh --build
- name: get list of file to upload
id: fileindex
run: |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "FILES<<$EOF" >> $GITHUB_OUTPUT
dasel -f index.toml -r toml -s "files.all().file" >> $GITHUB_OUTPUT
echo "$EOF" >> $GITHUB_OUTPUT
- name: upload artifact (packwiz)
uses: actions/upload-artifact@v3
with:
name: "packwiz-modpack"
path: |
pack.toml
index.toml
README.md
${{ steps.fileindex.outputs.FILES }}
- name: Cache Mods
id: cache-mods
uses: actions/cache@v3
with:
path: ~/.cache/packwiz/cache
key: ${{ runner.os }}-packwiz-${{ hashFiles('index.toml') }}
restore-keys: ${{ runner.os }}-packwiz
- name: build modrinth format modpack
run: packwiz modrinth export -o ${{ env.target-name }}.mrpack
- name: upload artifact (modrinth)
uses: actions/upload-artifact@v3
with:
name: "modrinth-modpack"
path: "${{ env.target-name }}.mrpack"
release:
needs: build-artifacts
if: ${{ github.ref_type == 'tag' }}
name: Release to modrinth and github
runs-on: ubuntu-22.04
steps:
- name: Fetch Modrinth Modpack
uses: actions/download-artifact@v3
with:
name: modrinth-modpack
- name: Fetch Packwiz Modpack
uses: actions/download-artifact@v3
with:
name: packwiz-modpack
path: pw-modpack
- name: Create ${{ env.target-name }}.packwiz.zip
run: zip -rq ${{ env.target-name }}.packwiz pw-modpack/ # ${{ env.target-name }}.packwiz.zip
- name: Create Modrinth Release
id: modrinth-release
if: false
uses: Kir-Antipov/mc-publish@v3.2
with:
modrinth-id: ${{ secrets.MODRINTH_PROJECT }}
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
modrinth-featured: ${{ !(contains(github.ref, '-rc.')) }}
modrinth-unfeature-mode: ${{ ((contains(github.ref, '-rc.')) && 'none') || 'any' }} # "any" if production deploy, none otherwise
files-primary: "${{ env.target-name }}.mrpack"
files-extra: "${{ env.target-name }}.packwiz.zip"
version-type: ${{ ((contains(github.ref, '-rc.')) && 'beta') || 'release' }}
game-versions: 1.18.2
- name: Create Github Release
id: github-release
uses: softprops/action-gh-release@v1
with:
generate_release_notes: ${{ !(contains(github.ref, '-rc.')) }}
prerelease: ${{ contains(github.ref, '-rc.') }}
files: |
${{ env.target-name }}.mrpack
${{ env.target-name }}.packwiz.zip
- if: ((steps.github-release.conclusion == 'success') || (steps.modrinth-release.conclusion == 'success'))
run: echo "# Releases" >> $GITHUB_STEP_SUMMARY
- if: steps.github-release.conclusion == 'success'
run: |
echo "- [Github](${{ steps.github-release.outputs.url }})" >> $GITHUB_STEP_SUMMARY
- if: steps.modrinth-release.conclusion == 'success'
run: |
echo "- [Modrinth](https://modrinth.com/modpacks/${{secrets.MODRINTH_PROJECT}}/versions)" >> $GITHUB_STEP_SUMMARY
deploy:
name: Deploy packwiz GH Pages
concurrency: ci-${{ github.ref }}
runs-on: ubuntu-22.04
needs: build-artifacts
if: ${{ github.event_name != 'pull_request' }}
env:
ghpagebot-name: github-actions[bot]
ghpagebot-email: 41898282+github-actions[bot]@users.noreply.github.com
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3
- name: Fetch Packwiz Modpack
uses: actions/download-artifact@v3
with:
name: packwiz-modpack
path: pw-modpack
# if pr, skip.
# if branch -> push to branch/branchname
# if tag -> push to tag/tagname
# if tag -> push to latest
# if tag && not rc -> push to stable
- name: Deploy production
uses: JamesIves/github-pages-deploy-action@v4
if: ${{ github.ref_type == 'branch' }}
with:
folder: pw-modpack
branch: gh-pages
target-folder: branch/${{ github.ref_name }}
git-config-name: ${{ env.ghpagebot-name }}
git-config-email: ${{ env.ghpagebot-email }}
- name: Deploy production
uses: JamesIves/github-pages-deploy-action@v4
if: ${{ github.ref_type == 'tag' }}
with:
folder: pw-modpack
branch: gh-pages
target-folder: tag/${{ github.ref_name }}
git-config-name: ${{ env.ghpagebot-name }}
git-config-email: ${{ env.ghpagebot-email }}
- name: Deploy production
uses: JamesIves/github-pages-deploy-action@v4
if: ${{ github.ref_type == 'tag' }}
with:
folder: pw-modpack
branch: gh-pages
target-folder: rc
git-config-name: ${{ env.ghpagebot-name }}
git-config-email: ${{ env.ghpagebot-email }}
- name: Deploy production
uses: JamesIves/github-pages-deploy-action@v4
if: ${{ github.ref_type == 'tag' && !(contains(github.ref, '-rc.')) }}
with:
folder: pw-modpack
branch: gh-pages
target-folder: stable
git-config-name: ${{ env.ghpagebot-name }}
git-config-email: ${{ env.ghpagebot-email }}
# TODO
# Generate Changelog
# maybe generate a json file in the repo, and a workflow modifies readme.md from the template (so it should never be modified manually)
# packwiz list | sort
# wc -l -> number of mods
# readme.md -> list of mods in current branch?
# releases -> full list of mods behind <details><summary>
# full release -> diff of mods from last full release
# RC release -> diff of mods from last rc / full release
# publish readme, licence inside modpack + repo
# generated changelog file to be included