generated from ParadigmMC/mc-modpack-kit
-
Notifications
You must be signed in to change notification settings - Fork 1
185 lines (144 loc) · 6 KB
/
pipeline.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
name: Modpack Release | Pipeline
on:
push:
branches:
- main
env:
pack-file: 'pack.toml'
default-release-modrinth: 'true'
default-release-curseforge: 'false'
jobs:
parse-current-modpacks:
name: Parse current modpacks to a list
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
modpack-folders: ${{ steps.list-modpacks.outputs.modpack-folders }}
steps:
# -- Checkout repo
- name: Check Out Git Repository
uses: actions/checkout@v4
# --- Parse the modpacks to and list
# This just parses the folders that have pack.toml
- name: List Modpacks
id: list-modpacks
run: |
modpackFolders=()
for folder in *; do
if [ -d "$folder" ]; then
if [ -e "$folder/${{ env.pack-file }}" ]; then
modpackFolders+=("$folder")
fi
fi
done
echo "modpack-folders=$(jq --compact-output --null-input '$ARGS.positional' --args -- "${modpackFolders[@]}")" >> "$GITHUB_OUTPUT"
# --- Print an nice msg about parsing
- name: Current detected modpacks
run: |
echo "::notice ::⚙ Current detected modpacks: ${{ steps.list-modpacks.outputs.modpack-folders }}"
release-please:
needs:
- parse-current-modpacks
if: ${{ (needs.parse-current-modpacks.outputs.modpack-folders) != '[]' }}
strategy:
fail-fast: false
matrix:
modpack: ${{ fromJson(needs.parse-current-modpacks.outputs.modpack-folders) }}
name: Handle Releases
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ matrix.modpack }}
permissions:
contents: write
pull-requests: write
steps:
# --- Release please
# Creates and manages the prs and releases
- name: Perform Release with Release Please
id: release-please
uses: google-github-actions/release-please-action@v3
with:
monorepo-tags: true
path: ${{ matrix.modpack }}
release-type: simple
package-name: ${{ matrix.modpack }}
prerelease: true
changelog-types: >
[{"type":"feat","section":"★ Features","hidden":false},
{"type":"fix","section":"♻ Bug Fixes","hidden":false},
{"type":"mod","section":"☀ Modpack Changes","hidden":false},
{"type":"update","section":"⚘ Modpack Updates","hidden":false},
{"type":"chore","section":"⛭ Miscellaneous","hidden":true}]
# --- Parse version from PR Title when creating PR's
# Had to do this cause like to bump on the release pleae branch
# The tests for the shitty Regex can be found here: https://regexr.com/7lb8e
- name: Parse tag from PR title
uses: actions-ecosystem/action-regex-match@v2
id: version
with:
text: ${{ fromJson(steps.release-please.outputs.pr).title }}
regex: '(?<=\s)(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$'
if: ${{ steps.release-please.outputs.pr != '' }}
# --- Checkout the git repo
# Remembed to do this AFTER release please
- name: Check Out Git Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
# --- Bump version
# Now we should use the parsed release to bump the version on the files on the release please branch
- name: Bump Version
uses: ./.github/actions/bump-pack
with:
release-tag: ${{ steps.version.outputs.match }}
modpack: ${{ matrix.modpack }}
branch: ${{ fromJson(steps.release-please.outputs.pr).headBranchName }}
if: ${{ steps.release-please.outputs.pr != '' }}
# --- Get latest tag
# Should probably be switched to use the release please tag but whatever
- name: Get Latest tag
id: tag
uses: WyriHaximus/github-action-get-previous-tag@v1
if: ${{ steps.release-please.outputs.releases_created }}
# --- Handle the configs
- name: Parse Pack File
id: parse
uses: ./.github/actions/parse
with:
modpack: ${{ matrix.modpack }}
if: ${{ steps.release-please.outputs.releases_created }}
- name: Set Mod Vendors
id: set-mod-vendors
run: |
[[ ! -z "${{ secrets.CURSEFORGE_KEY }}" && ! -z "${{ secrets.CURSEFORGE_ID }}" ]] && echo "curseforge=true" >> $GITHUB_OUTPUT || echo "curseforge=false" >> $GITHUB_OUTPUT
[[ ! -z "${{ secrets.MODRINTH_KEY }}" && ! -z "${{ secrets.MODRINTH_ID }}" ]] && echo "modrinth=true" >> $GITHUB_OUTPUT || echo "modrinth=false" >> $GITHUB_OUTPUT
shell: bash
if: ${{ steps.release-please.outputs.releases_created }}
# --- Build an release
- name: Build Modpack
uses: ./.github/actions/build
with:
modpack: ${{ matrix.modpack }}
release-tag: ${{ steps.tag.outputs.tag }}
build-modrinth: ${{ env.default-release-modrinth }}
build-curse: ${{ env.default-release-curseforge }}
if: ${{ steps.release-please.outputs.releases_created }}
# --- Release
- name: Release Modpack to Vendors
uses: ./.github/actions/release
with:
modpack: ${{ matrix.modpack }}
release-tag: ${{ steps.tag.outputs.tag }}
loader: ${{ steps.parse.outputs.loader }}
game-version: ${{ steps.parse.outputs.game-version }}
upload-modrinth: ${{ steps.set-mod-vendors.outputs.modrinth }}
upload-curse: ${{ steps.set-mod-vendors.outputs.curseforge }}
MODRINTH_ID: ${{ secrets.MODRINTH_ID }}
MODRINTH_KEY: ${{ secrets.MODRINTH_KEY }}
CURSEFORGE_ID: ${{ secrets.CURSEFORGE_ID }}
CURSEFORGE_KEY: ${{ secrets.CURSEFORGE_KEY }}
if: |
steps.release-please.outputs.releases_created &&
(steps.set-mod-vendors.outputs.modrinth || steps.set-mod-vendors.outputs.curseforge)