-
-
Notifications
You must be signed in to change notification settings - Fork 1
160 lines (140 loc) · 7.45 KB
/
publish.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
name: "Publish"
on:
workflow_dispatch:
inputs:
mod_loaders:
description: 'List of mod loaders to be published'
required: true
default: "['fabric', 'forge', 'neoforge']"
type: string
branches:
description: 'List of branches to be published'
required: true
default: "['1.19.2', '1.19.3', '1.19.4', '1.20.1', '1.20.2', '1.20.4', '1.20.6', '1.21']"
type: string
jobs:
publish:
runs-on: ubuntu-latest
name: Publish ${{ matrix.branch }} ${{ matrix.mod_loader }}
timeout-minutes: 60
strategy:
max-parallel: 3
fail-fast: false
matrix:
branch: ${{ fromJson(inputs.branches) }}
mod_loader: ${{ fromJson(inputs.mod_loaders) }}
include:
- mod_loader: "fabric"
supported_mod_loaders: [ "fabric", "quilt" ]
secondary_game_version: ""
curseforge_id: ${{ vars.CURSEFORGE_FABRIC_PROJECT_ID }}
modrinth_id: ${{ vars.MODRINTH_FABRIC_PROJECT_ID }}
- mod_loader: "forge"
supported_mod_loaders: [ "forge" ]
secondary_game_version: ""
curseforge_id: ${{ vars.CURSEFORGE_FORGE_PROJECT_ID }}
modrinth_id: ${{ vars.MODRINTH_FORGE_PROJECT_ID }}
- mod_loader: "neoforge"
supported_mod_loaders: [ "neoforge" ]
secondary_game_version: ""
curseforge_id: ${{ vars.CURSEFORGE_FORGE_PROJECT_ID }}
modrinth_id: ${{ vars.MODRINTH_FORGE_PROJECT_ID }}
steps:
- name: "Checkout repository"
uses: actions/[email protected]
with:
ref: ${{ matrix.branch }}
fetch-depth: 0
- name: "Check if the mod loader is supported"
id: check-mod-loader
run: |
if [ -d ${{ matrix.mod_loader }} ]; then
echo "Mod loader is supported"
echo "is_mod_loader_supported=true" >> $GITHUB_OUTPUT
else
echo "Mod loader is not supported"
echo "is_mod_loader_supported=false" >> $GITHUB_OUTPUT
fi
- name: "Parse gradle properties"
if: steps.check-mod-loader.outputs.is_mod_loader_supported == 'true'
id: gradle-properties
run: |
while IFS='=' read -r key value; do
key=$(echo $key | awk '{$1=$1;print}')
value=$(echo $value | awk '{$1=$1;print}')
case "$key" in
minecraft_version) echo "MINECRAFT_VERSION=$value" >> $GITHUB_OUTPUT ;;
mod_name) echo "MOD_NAME=$value" >> $GITHUB_OUTPUT ;;
mod_version) echo "MOD_VERSION=$value" >> $GITHUB_OUTPUT ;;
esac
done < gradle.properties
- name: "Parse changelog"
if: steps.check-mod-loader.outputs.is_mod_loader_supported == 'true'
id: parse-changelog
run: |
changelog=$(cat CHANGELOG.md)
tag=${{ steps.gradle-properties.outputs.MOD_VERSION }}
list=$(echo "$changelog" | sed -n "/^## $tag/,/^## [0-9]/p" | sed -e '1d;$d' -e '/^$/d')
echo "$list" > RELEASE_CHANGELOG.md
- name: "Create github release"
if: steps.check-mod-loader.outputs.is_mod_loader_supported == 'true'
continue-on-error: true
uses: ncipollo/release-action@v1
with:
skipIfReleaseExists: true
allowUpdates: true
omitNameDuringUpdate: true
omitBodyDuringUpdate: true
tag: mc${{ steps.gradle-properties.outputs.MINECRAFT_VERSION }}-${{ steps.gradle-properties.outputs.MOD_VERSION }}
name: ${{ steps.gradle-properties.outputs.MOD_NAME }} ${{ steps.gradle-properties.outputs.MOD_VERSION }} for Minecraft ${{ steps.gradle-properties.outputs.MINECRAFT_VERSION }}
bodyFile: RELEASE_CHANGELOG.md
- name: "Set up JDK 17"
if: steps.check-mod-loader.outputs.is_mod_loader_supported == 'true' && steps.gradle-properties.outputs.MINECRAFT_VERSION != '1.20.6' && steps.gradle-properties.outputs.MINECRAFT_VERSION != '1.21'
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
- name: "Set up JDK 21"
if: steps.check-mod-loader.outputs.is_mod_loader_supported == 'true' && steps.gradle-properties.outputs.MINECRAFT_VERSION == '1.20.6' || steps.gradle-properties.outputs.MINECRAFT_VERSION == '1.21'
uses: actions/setup-java@v4
with:
java-version: 21
distribution: temurin
- name: "Setup gradle and run build"
if: steps.check-mod-loader.outputs.is_mod_loader_supported == 'true'
uses: gradle/[email protected]
with:
cache-read-only: true
generate-job-summary: false
gradle-version: wrapper
arguments: ${{ matrix.mod_loader }}:build
- name: Publish ${{ matrix.mod_loader }}
if: steps.check-mod-loader.outputs.is_mod_loader_supported == 'true'
uses: Kir-Antipov/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
github-tag: mc${{ steps.gradle-properties.outputs.MINECRAFT_VERSION }}-${{ steps.gradle-properties.outputs.MOD_VERSION }}
github-commitish: ${{ steps.gradle-properties.outputs.MINECRAFT_VERSION }}
curseforge-id: ${{ matrix.curseforge_id }}
curseforge-token: ${{ secrets.CURSEFORGE_RELEASE_TOKEN }}
modrinth-id: ${{ matrix.modrinth_id }}
modrinth-featured: true
modrinth-token: ${{ secrets.MODRINTH_RELEASE_TOKEN }}
name: ${{ steps.gradle-properties.outputs.MOD_NAME }} ${{ steps.gradle-properties.outputs.MOD_VERSION }}
version: ${{ matrix.mod_loader }}-mc${{ steps.gradle-properties.outputs.MINECRAFT_VERSION }}-${{ steps.gradle-properties.outputs.MOD_VERSION }}
loaders: ${{ join(matrix.supported_mod_loaders, ' ') }}
game-versions: "${{ matrix.branch }}\n${{ matrix.secondary_game_version }}"
changelog-file: RELEASE_CHANGELOG.md
files: |
${{ matrix.mod_loader }}/build/libs/!(*-@(dev|dev-shadow|sources|javadoc)).jar
clear-cache:
needs: publish
runs-on: ubuntu-latest
name: "Clear cache"
timeout-minutes: 60
steps:
- uses: MyAlbum/purge-cache@v2
with:
accessed: true
created: true
max-age: 21600