-
Notifications
You must be signed in to change notification settings - Fork 184
176 lines (170 loc) · 6.17 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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
name: Publish Version
on:
workflow_call:
inputs:
simulate:
required: false
type: boolean
branch:
description: 'Branch to checkout; 1.20.1 or 1.21'
required: true
type: string
tag-name:
description: 'Tag to upload to'
required: true
type: string
release-body:
description: 'Body for published release notes'
required: false
type: string
changelog-body:
description: 'Body of change notes to insert into CHANGELOG.md'
required: false
type: string
jobs:
build:
name: Build and Publish to Maven
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
ver: ${{ steps.ver.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}
- name: Setup Build
uses: ./.github/actions/build_setup
with:
ref: ${{ inputs.branch }}
- name: Get Version
id: ver
run: echo "version=$(./gradlew -q printVersion)" >> $GITHUB_OUTPUT
- name: Build
run: ./gradlew assemble --build-cache
- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts-${{ inputs.branch }}
path: build/libs/*
if-no-files-found: error
retention-days: 3
- name: Publish
if: ${{ !inputs.simulate }}
env:
MAVEN_USER: ${{ secrets.MAVEN_USER }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
run: ./gradlew publish --build-cache
upload-release-artifacts:
name: Upload Artifacts
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: build-artifacts-${{ inputs.branch }}
- name: Upload artifacts to release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ inputs.tag-name }}
files: ./*.jar
fail_on_unmatched_files: true
publish-modrinth:
name: Publish to Modrinth
needs: build
if: ${{ !inputs.simulate }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: build-artifacts-${{ inputs.branch }}
- name: Publish Mod
env:
MC_VERSION: ${{ inputs.branch == '1.21' && '1.21.1' || '1.20.1' }}
LOADER: ${{ inputs.branch == '1.21' && 'neoforge' || 'forge' }}
JAVA: ${{ inputs.branch == '1.21' && '21' || '17' }}
VERSION_TYPE: ${{ inputs.branch == '1.21' && 'alpha' || 'beta' }}
uses: Kir-Antipov/[email protected]
with:
modrinth-id: 7tG215v7
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
files: |
./gtceu-${{ env.MC_VERSION }}-${{ needs.build.outputs.ver }}.jar
./!(gtceu-${{ env.MC_VERSION }}-${{ needs.build.outputs.ver }}.jar)
name: 'GregTechCEu ${{ env.MC_VERSION }}-${{ needs.build.outputs.ver }}'
version: 'mc${{ env.MC_VERSION }}-${{ needs.build.outputs.ver }}'
version-type: ${{ env.VERSION_TYPE }}
changelog: ${{ inputs.release-body }}
loaders: ${{ env.LOADER }}
java: ${{ env.JAVA }}
fail-mode: fail
publish-cf:
name: Publish to CF
needs: build
if: ${{ !inputs.simulate }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: build-artifacts-${{ inputs.branch }}
- name: Publish Mod
env:
MC_VERSION: ${{ inputs.branch == '1.21' && '1.21.1' || '1.20.1' }}
LOADER: ${{ inputs.branch == '1.21' && 'neoforge' || 'forge' }}
JAVA: ${{ inputs.branch == '1.21' && '21' || '17' }}
VERSION_TYPE: ${{ inputs.branch == '1.21' && 'alpha' || 'beta' }}
uses: Kir-Antipov/[email protected]
with:
curseforge-id: 890405
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
files: |
./gtceu-${{ env.MC_VERSION }}-${{ needs.build.outputs.ver }}.jar
./!(gtceu-${{ env.MC_VERSION }}-${{ needs.build.outputs.ver }}.jar)
name: 'GregTechCEu ${{ env.MC_VERSION }}-${{ needs.build.outputs.ver }}'
version: 'mc${{ env.MC_VERSION }}-${{ needs.build.outputs.ver }}'
version-type: ${{ env.VERSION_TYPE }}
changelog: ${{ inputs.release-body }}
loaders: ${{ env.LOADER }}
java: ${{ env.JAVA }}
fail-mode: fail
# After successful release, PR version bump and changelog
bump-version-and-changelog:
name: Bump Version and Build Changelog
needs: [ build, upload-release-artifacts, publish-modrinth, publish-cf]
if: ${{ always() && !failure() && !cancelled() }}
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}
- name: Bump Version
run: |
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git switch -C gh/release-${{ inputs.branch }}
BUMPED=$(echo ${{ needs.build.outputs.ver }} | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.)
sed -i "s/= ${{ needs.build.outputs.ver }}/= ${BUMPED}/" gradle.properties
git commit -am "Bump version to ${BUMPED}"
- name: Prepend to CHANGELOG
if: inputs.changelog-body
run: |
{ head -n 2 CHANGELOG.md; echo -e "${{ inputs.changelog-body }}"; tail -n +3 CHANGELOG.md; } > temp.md && mv temp.md CHANGELOG.md
git commit -am "Updated CHANGELOG"
- name: Push and PR
env:
GH_TOKEN: ${{ github.token }}
run: |
git push --force --set-upstream origin gh/release-${{ inputs.branch }}
gh pr create -B ${{ inputs.branch }} -H gh/release-${{ inputs.branch }} --title "RELEASE for ${{ inputs.branch }}" --body "Created by GH Workflow" --label "ignore changelog"