-
-
Notifications
You must be signed in to change notification settings - Fork 16
186 lines (185 loc) · 7.18 KB
/
publish-release.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
186
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
jobs:
create-release:
runs-on: ubuntu-latest
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:
- name: Checkout repository
uses: actions/checkout@v4
- name: Extracting version from properties
shell: bash
run: echo "version=$(cat gradle.properties | grep -w "\bversion" | cut -d= -f2)" >> $GITHUB_OUTPUT
id: extract-version
- name: Bumping version
uses: TwelveIterationMods/bump-version@v1
with:
version: ${{ steps.extract-version.outputs.version }}
bump: patch
id: bump-version
- name: Updating version properties
run: |
sed -i "s/^\s*version\s*=.*/version = ${{ steps.bump-version.outputs.version }}/g" gradle.properties
git config user.name "GitHub Actions"
git config user.email "<>"
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@v7
with:
script: |
const fs = require('fs');
const settingsGradle = fs.readFileSync('settings.gradle', 'utf8');
const includePattern = /^(?!\s*\/\/)\s*include\s*\(\s*["']([^"']+)["']\s*\)/gm;
const includes = [...settingsGradle.matchAll(includePattern)].map(match => match[1]);
const includeFabric = includes.includes('fabric') && ${{inputs.fabric}};
const includeForge = includes.includes('forge') && ${{inputs.forge}};
const includeNeoForge = includes.includes('neoforge') && ${{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@v7
with:
script: |
const fs = require('fs');
const settingsGradle = fs.readFileSync('settings.gradle', 'utf8');
const includePattern = /^(?!\s*\/\/)\s*include\s*\(\s*["']([^"']+)["']\s*\)/gm;
const includes = [...settingsGradle.matchAll(includePattern)].map(match => match[1]);
const includeFabric = includes.includes('fabric') && ${{inputs.fabric}};
const includeForge = includes.includes('forge') && ${{inputs.forge}};
const includeNeoForge = includes.includes('neoforge') && ${{inputs.neoforge}};
return {
loader: ['common', includeFabric ? 'fabric' : false, includeForge ? 'forge' : false, includeNeoForge ? 'neoforge' : false].filter(Boolean),
site: ['curseforge', 'modrinth', 'publish'],
exclude: [
{loader: 'common', site: 'curseforge'},
{loader: 'common', site: 'modrinth'}
]
}
build-common:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ needs.create-release.outputs.ref }}
- name: Validate gradle wrapper
uses: gradle/actions/wrapper-validation@v3
- name: Setup JDK
uses: actions/setup-java@v4
with:
java-version: 21
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@v4
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@v4
with:
ref: ${{ needs.create-release.outputs.ref }}
- name: Validate gradle wrapper
uses: gradle/actions/wrapper-validation@v3
- name: Setup JDK
uses: actions/setup-java@v4
with:
java-version: 21
distribution: temurin
cache: 'gradle'
- name: Make gradle wrapper executable
run: chmod +x ./gradlew
- name: Download common artifact
uses: actions/download-artifact@v4
with:
name: common-artifact
path: common/build
- 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@v4
with:
name: ${{ matrix.loader }}-artifact
path: ${{ matrix.loader }}/build
needs:
- create-release
- build-common
publish-release:
runs-on: ubuntu-latest
strategy:
matrix: ${{fromJson(needs.create-release.outputs.publish-matrix)}}
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ needs.create-release.outputs.ref }}
- name: Download ${{ matrix.loader }} artifact
uses: actions/download-artifact@v4
with:
name: ${{ matrix.loader }}-artifact
path: ${{ matrix.loader }}/build
- name: Validate gradle wrapper
uses: gradle/actions/wrapper-validation@v3
- name: Setup JDK
uses: actions/setup-java@v4
with:
java-version: 21
distribution: temurin
cache: 'gradle'
- name: Make gradle wrapper executable
run: chmod +x ./gradlew
- name: Check current artifact hash TODO
run: sha1sum ${{ matrix.loader }}/build/libs/*
- name: Publish
run: ./gradlew :${{ matrix.loader }}:${{ matrix.site }} '-Pversion=${{needs.create-release.outputs.version}}' '-PtwelveIterationsNexusUsername=${{ secrets.NEXUS_USER }}' '-PtwelveIterationsNexusPassword=${{ secrets.NEXUS_PASSWORD }}'
env:
CURSEFORGE_TOKEN: ${{secrets.CURSEFORGE_TOKEN}}
MODRINTH_TOKEN: ${{secrets.MODRINTH_TOKEN}}
- name: Check new artifact hash TODO
run: sha1sum ${{ matrix.loader }}/build/libs/*
needs:
- create-release
- build-common
- build-release