-
Notifications
You must be signed in to change notification settings - Fork 1
162 lines (140 loc) · 5.62 KB
/
Copy pathrelease.yml
File metadata and controls
162 lines (140 loc) · 5.62 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
name: Multi-Release
on:
workflow_dispatch:
inputs:
release-body:
description: "Changelog for this release"
type: string
required: false
default: ""
run-tests:
description: "Run game tests after build"
type: boolean
required: false
default: false
permissions:
contents: write
jobs:
setup:
runs-on: ubuntu-24.04
outputs:
matrix: ${{ steps.gen_matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- id: gen_matrix
run: |
ENTRIES=$(jq -c '[.versions[] | {version, mc_src: (.mcVersion // .version), mc_ver: .minecraft_version, fabric_api: .fabric_api_version, yarn: (.yarn_mappings // ""), loader: (.loader_version // "")}]' versions.json)
FILTERED="[]"
while read -r entry; do
MC_SRC=$(echo "$entry" | jq -r '.mc_src')
if [ -d "src/mc-$MC_SRC" ]; then
FILTERED=$(echo "$FILTERED" | jq -c ". + [$entry]")
fi
done < <(echo "$ENTRIES" | jq -c '.[]')
echo "matrix={\"include\": $FILTERED}" >> $GITHUB_OUTPUT
build:
needs: setup
runs-on: ubuntu-24.04
strategy:
matrix: ${{ fromJSON(needs.setup.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: "25"
distribution: "zulu"
cache: "gradle"
- name: Make gradle wrapper executable
run: chmod +x ./gradlew
- name: Skip if no source directory
id: check_src
run: |
if [ -d "src/mc-${{ matrix.mc_src }}" ]; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Build ${{ matrix.version }}
if: steps.check_src.outputs.exists == 'true'
run: |
PROPS=(-DmcVersion="${{ matrix.mc_src }}" -PmcVersion="${{ matrix.mc_src }}" -Pminecraft_version="${{ matrix.mc_ver }}" -Pfabric_api_version="${{ matrix.fabric_api }}")
[ -n "${{ matrix.yarn }}" ] && PROPS+=(-Pyarn_mappings="${{ matrix.yarn }}")
[ -n "${{ matrix.loader }}" ] && PROPS+=(-Ploader_version="${{ matrix.loader }}")
./gradlew clean build "${PROPS[@]}" --no-daemon -q
- name: Run game tests
if: steps.check_src.outputs.exists == 'true' && github.event.inputs.run-tests == 'true' && !startsWith(matrix.mc_src, '26')
run: |
PROPS=(-DmcVersion="${{ matrix.mc_src }}" -PmcVersion="${{ matrix.mc_src }}" -Pminecraft_version="${{ matrix.mc_ver }}" -Pfabric_api_version="${{ matrix.fabric_api }}" -PenableGameTests=true)
[ -n "${{ matrix.yarn }}" ] && PROPS+=(-Pyarn_mappings="${{ matrix.yarn }}")
[ -n "${{ matrix.loader }}" ] && PROPS+=(-Ploader_version="${{ matrix.loader }}")
./gradlew runGameTest "${PROPS[@]}" --no-daemon -q
- name: Get mod version
if: steps.check_src.outputs.exists == 'true'
id: mod_info
run: echo "mod_version=$(grep '^mod_version' gradle.properties | cut -d= -f2)" >> $GITHUB_OUTPUT
- name: Rename and upload JAR
if: steps.check_src.outputs.exists == 'true'
run: |
MODVER="${{ steps.mod_info.outputs.mod_version }}"
mv "build/libs/stackabletools-${MODVER}.jar" "build/libs/stackabletools-${MODVER}-mc${{ matrix.version }}.jar"
- name: Upload artifact
if: steps.check_src.outputs.exists == 'true'
uses: actions/upload-artifact@v4
with:
name: jar-mc-${{ matrix.version }}
path: build/libs/stackabletools-*.jar
release:
needs: build
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download all JARs
uses: actions/download-artifact@v4
with:
path: dist-jars
- name: Collect JARs
run: |
mkdir -p dist
find dist-jars -name "*.jar" -exec cp {} dist/ \;
echo "Collected JARs:"
ls -lh dist/
- name: Bump version and push tag
id: version_tag
run: |
git config user.name "github-actions"
git config user.email "github-actions@github.com"
increment_version() {
local v=$1
local major=$(echo "$v" | cut -d. -f1)
local minor=$(echo "$v" | cut -d. -f2)
local patch=$(echo "$v" | cut -d. -f3)
echo "$major.$minor.$((patch + 1))"
}
VERSION=$(grep '^mod_version' gradle.properties | cut -d= -f2)
git fetch --tags
while git rev-parse "v$VERSION" >/dev/null 2>&1; do
VERSION=$(increment_version "$VERSION")
done
CURRENT_VERSION=$(grep '^mod_version' gradle.properties | cut -d= -f2)
if [ "$VERSION" != "$CURRENT_VERSION" ]; then
sed -i "s/^mod_version=$CURRENT_VERSION/mod_version=$VERSION/" gradle.properties
git add gradle.properties
git commit -m "chore: bump version to $VERSION [skip ci]"
git push origin "${GITHUB_REF#refs/heads/}"
fi
git tag "v$VERSION"
git push origin "v$VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.version_tag.outputs.version }}
name: Release v${{ steps.version_tag.outputs.version }}
body: ${{ github.event.inputs.release-body }}
generate_release_notes: true
files: dist/*.jar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}