-
Notifications
You must be signed in to change notification settings - Fork 4
182 lines (161 loc) · 5.01 KB
/
Build.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
name: Build
run-name: "Build #${{ github.run_number }}"
on:
push:
tags:
- 'v*'
branches:
- main
paths-ignore:
- 'docs/**'
- '*.md'
pull_request:
paths-ignore:
- 'docs/**'
- '*.md'
jobs:
changelog:
name: Changelog
runs-on: ubuntu-latest
outputs:
latest_tag: ${{ steps.changelog.outputs.latest_tag }}
version: ${{ steps.changelog.outputs.version }}
rel_type: ${{ steps.changelog.outputs.rel_type }}
changelog_text: ${{ steps.changelog.outputs.changelog_text }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get Changelog
id: changelog
shell: bash
run: |
latest_tag=$(git describe --tags --abbrev=0)
{ grep --color=auto -Pzo "(?<=## $latest_tag)((?!\n## )[\s\S])*" ./CHANGELOG.md || true; } | sed '$ s/.$//' > ./NEW_CHANGELOG.md
rel_type="release"
case $latest_tag in
*alpha*) rel_type="alpha" ;;
*beta*) rel_type="beta" ;;
*) rel_type="release" ;;
esac
echo "latest_tag=$latest_tag" >> $GITHUB_OUTPUT
echo "version=${latest_tag/v}" >> $GITHUB_OUTPUT
echo "rel_type=$rel_type" >> $GITHUB_OUTPUT
{
echo 'changelog_text<<EOF'
cat ./NEW_CHANGELOG.md
echo EOF
} >> $GITHUB_OUTPUT
- name: Upload Changelog
uses: actions/upload-artifact@v4
with:
name: changelog
path: ${{ github.workspace }}/NEW_CHANGELOG.md
build-jvm-jar:
name: Build JVM Jar
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
cache: 'gradle'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build the mod
run: ./gradlew --no-daemon build
- name: Upload JVM Jar
uses: actions/upload-artifact@v4
with:
name: jvm-jar
path: build/libs/*
release-github:
name: Release GitHub
runs-on: ubuntu-latest
needs: [changelog, build-jvm-jar]
permissions:
contents: write
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Download Artifact Changelog
uses: actions/download-artifact@v4
with:
name: changelog
- name: Download Artifact JVM Jar
uses: actions/download-artifact@v4
with:
name: jvm-jar
path: jar
- name: Create release
uses: softprops/action-gh-release@v1
with:
body_path: ./NEW_CHANGELOG.md
prerelease: false
token: ${{ secrets.PUSH_ACCESS_TOKEN }}
files: |
jar/*
release-curseforge:
name: Release CurseForge
runs-on: ubuntu-latest
needs: [changelog, build-jvm-jar]
permissions:
contents: write
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Download Artifact Changelog
uses: actions/download-artifact@v4
with:
name: changelog
- name: Download Artifact JVM Jar
uses: actions/download-artifact@v4
with:
name: jvm-jar
path: jar
- name: Create release
id: cf_release
uses: itsmeow/[email protected]
with:
token: ${{ secrets.CF_TOKEN }}
project_id: 574029
file_path: jar/Greenery-1.12.2-${{ needs.changelog.outputs.version }}.jar
display_name: Greenery-1.12.2-${{ needs.changelog.outputs.version }}
changelog: ${{ needs.changelog.outputs.changelog_text }}
changelog_type: markdown
game_versions: "Minecraft 1.12.2, Forge"
game_endpoint: minecraft
release_type: ${{ needs.changelog.outputs.rel_type }}
release-modrinth:
name: Release Modrinth
runs-on: ubuntu-latest
needs: [changelog, build-jvm-jar]
permissions:
contents: write
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Download Artifact Changelog
uses: actions/download-artifact@v4
with:
name: changelog
- name: Download Artifact JVM Jar
uses: actions/download-artifact@v4
with:
name: jvm-jar
path: jar
- name: Upload to Modrinth
uses: dsx137/[email protected]
env:
MODRINTH_TOKEN: ${{ secrets.MR_TOKEN }}
with:
name: Greenery-1.12.2-${{ needs.changelog.outputs.version }}
project_id: EVaCo3rr
loaders: forge
game_versions: 1.12.2, 1.12.1, 1.12
version_number: ${{ needs.changelog.outputs.version }}
changelog: ${{ needs.changelog.outputs.changelog_text }}
version_type: ${{ needs.changelog.outputs.rel_type }}
files: |
jar/Greenery-1.12.2-${{ needs.changelog.outputs.version }}.jar