Skip to content

Commit f7e9110

Browse files
committed
ci: add auto publish actions
1 parent ebed851 commit f7e9110

File tree

2 files changed

+191
-2
lines changed

2 files changed

+191
-2
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ name: build
22

33
on: [
44
pull_request,
5-
push
5+
push,
6+
workflow_call
67
]
78

89
jobs:
@@ -44,5 +45,5 @@ jobs:
4445
if: ${{ runner.os == 'Linux' && matrix.java == '17' }}
4546
uses: actions/upload-artifact@v3.1.2
4647
with:
47-
name: Artifacts
48+
name: artifacts
4849
path: out/

.github/workflows/publish.yml

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
name: publish
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Mod version (without character v)'
8+
required: true
9+
type: string
10+
release_type:
11+
description: 'alpha, beta or release'
12+
required: true
13+
type: string
14+
debug:
15+
description: 'show details for debug'
16+
required: true
17+
default: true
18+
type: boolean
19+
20+
jobs:
21+
publish:
22+
if: ${{ github.event.ref_type == 'branch' && github.ref == 'refs/heads/master' }}
23+
runs-on: ubuntu-latest
24+
permissions:
25+
contents: write
26+
steps:
27+
- name: checkout repository
28+
uses: actions/checkout@v3.5.3
29+
- name: build
30+
uses: ./.github/workflows/build.yml
31+
- name: download build artifacts
32+
uses: actions/download-artifact@v3
33+
with:
34+
name: artifacts
35+
path: artifacts
36+
37+
- name: sort artifacts by game version
38+
run: |
39+
mkdir processed_artifacts
40+
mkdir processed_artifacts/17
41+
mkdir processed_artifacts/18
42+
mkdir processed_artifacts/19
43+
mkdir processed_artifacts/20
44+
cp artifacts/*1.17*.jar processed_artifacts/17
45+
cp artifacts/*1.18*.jar processed_artifacts/18
46+
cp artifacts/*1.19*.jar processed_artifacts/19
47+
cp artifacts/*1.20*.jar processed_artifacts/20
48+
49+
- name: show details for debug
50+
if: ${{ inputs.debug == true }}
51+
run: |
52+
apt install tree -y
53+
echo @@@@@###########################################@@@@@
54+
echo @@@@@###########################################@@@@@
55+
echo #### Mod version: ${{ inputs.version }}
56+
echo #### Release type: ${{ inputs.release_type }}
57+
echo #### Modrinth project id: SB7oe4aB
58+
echo #### Curseforge project id: 891699
59+
echo #### Downloaded artifacts:
60+
ls artifacts
61+
echo #### Processed artifacts:
62+
tree processed_artifacts
63+
echo @@@@@###########################################@@@@@
64+
echo @@@@@###########################################@@@@@
65+
continue-on-error: true
66+
67+
- name: Publish GitHub Release
68+
uses: release-drafter/release-drafter@v5
69+
env:
70+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
with:
72+
name-template: 'v${{ inputs.version }} For Minecraft 1.17, 1.18, 1.19.3 and 1.20.1'
73+
tag-template: 'v${{ inputs.version }}'
74+
template: |
75+
## Change Log
76+
77+
$CHANGES
78+
prerelease: ${{ contains('alpha', inputs.release_type) || contains('beta', inputs.release_type) }}
79+
continue-on-error: true
80+
- name: Publish Minecraft Mods 1.17
81+
uses: Kir-Antipov/mc-publish@v3.3
82+
with:
83+
modrinth-id: SB7oe4aB
84+
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
85+
86+
curseforge-id: 891699
87+
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
88+
89+
files: processed_artifacts/17/*.jar
90+
91+
name: v${{ inputs.version }} For Minecraft 1.17
92+
version: v${{ inputs.version }}
93+
version-type: ${{ inputs.release_type }}
94+
95+
loaders: fabric
96+
game-versions: '1.17'
97+
game-version-filter: any
98+
dependencies: |-
99+
carpet(required)
100+
fabric-api(required)
101+
102+
modrinth-changelog: 'Got full change logs in [GitHub](https://github.com/OptiJava/OptCarpetAddition/releases).'
103+
curseforge-changelog: 'Got full change logs in [GitHub](https://github.com/OptiJava/OptCarpetAddition/releases).'
104+
105+
retry-attempts: 3
106+
retry-delay: 10000
107+
108+
- name: Publish Minecraft Mods 1.18
109+
uses: Kir-Antipov/mc-publish@v3.3
110+
with:
111+
modrinth-id: SB7oe4aB
112+
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
113+
114+
curseforge-id: 891699
115+
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
116+
117+
files: processed_artifacts/18/*.jar
118+
119+
name: v${{ inputs.version }} For Minecraft 1.18
120+
version: v${{ inputs.version }}
121+
version-type: ${{ inputs.release_type }}
122+
123+
loaders: fabric
124+
game-versions: '1.18'
125+
game-version-filter: any
126+
dependencies: |-
127+
carpet(required)
128+
fabric-api(required)
129+
130+
modrinth-changelog: 'Got full change logs in [GitHub](https://github.com/OptiJava/OptCarpetAddition/releases).'
131+
curseforge-changelog: 'Got full change logs in [GitHub](https://github.com/OptiJava/OptCarpetAddition/releases).'
132+
133+
retry-attempts: 3
134+
retry-delay: 10000
135+
- name: Publish Minecraft Mods 1.19.3
136+
uses: Kir-Antipov/mc-publish@v3.3
137+
with:
138+
modrinth-id: SB7oe4aB
139+
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
140+
141+
curseforge-id: 891699
142+
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
143+
144+
files: processed_artifacts/19/*.jar
145+
146+
name: v${{ inputs.version }} For Minecraft 1.19.3
147+
version: v${{ inputs.version }}
148+
version-type: ${{ inputs.release_type }}
149+
150+
loaders: fabric
151+
game-versions: '1.19.3'
152+
game-version-filter: any
153+
dependencies: |-
154+
carpet(required)
155+
fabric-api(required)
156+
157+
modrinth-changelog: 'Got full change logs in [GitHub](https://github.com/OptiJava/OptCarpetAddition/releases).'
158+
curseforge-changelog: 'Got full change logs in [GitHub](https://github.com/OptiJava/OptCarpetAddition/releases).'
159+
160+
retry-attempts: 3
161+
retry-delay: 10000
162+
- name: Publish Minecraft Mods 1.20.1
163+
uses: Kir-Antipov/mc-publish@v3.3
164+
with:
165+
modrinth-id: SB7oe4aB
166+
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
167+
168+
curseforge-id: 891699
169+
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
170+
171+
files: processed_artifacts/20/*.jar
172+
173+
name: v${{ inputs.version }} For Minecraft 1.20.1
174+
version: v${{ inputs.version }}
175+
version-type: ${{ inputs.release_type }}
176+
177+
loaders: fabric
178+
game-versions: '1.20.1'
179+
game-version-filter: any
180+
dependencies: |-
181+
carpet(required)
182+
fabric-api(required)
183+
184+
modrinth-changelog: 'Got full change logs in [GitHub](https://github.com/OptiJava/OptCarpetAddition/releases).'
185+
curseforge-changelog: 'Got full change logs in [GitHub](https://github.com/OptiJava/OptCarpetAddition/releases).'
186+
187+
retry-attempts: 3
188+
retry-delay: 10000

0 commit comments

Comments
 (0)