-
Notifications
You must be signed in to change notification settings - Fork 23
139 lines (130 loc) · 4.8 KB
/
autobuild.yaml
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
name: Build and upload mod
on:
push:
branches:
- '1.19'
release:
types: [ published ]
branches:
- '1.19'
jobs:
setup:
if: ${{ contains(github.event.head_commit.message, 'version bump for release') && github.event_name != 'release' }}
name: Generate file path
runs-on: ubuntu-latest
outputs:
mod_name: ${{steps.moddetails.outputs.mod_name}}
mod_version: ${{steps.moddetails.outputs.mod_version}}
java_version: ${{steps.moddetails.outputs.java_version}}
mc_patch_version: ${{steps.patchversion.outputs.mc_patch_version}}
mc_minor_version: ${{steps.minorversion.outputs.mc_minor_version}}
file_path: ${{steps.filepath.outputs.file_path}}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Get Details
id: moddetails
run: |
echo "mod_name=$(cat ./build.gradle | sed -n 's/archivesBaseName \= //p' | tr -d "'")" >> $GITHUB_OUTPUT
echo "mod_version=$(cat ./build.gradle | sed -n 's/version \= //p' | tr -d "'")" >> $GITHUB_OUTPUT
echo "java_version=$(cat ./build.gradle | grep -o -P '(?<=JavaLanguageVersion.of\().*(?=\))')" >> $GITHUB_OUTPUT
- name: MC Patch Version
id: patchversion
run: echo "mc_patch_version=$(echo ${{ steps.moddetails.outputs.mod_version }} | awk -F- '{ print $1 }')" >> $GITHUB_OUTPUT
- name: MC Minor Version
id: minorversion
run: echo "mc_minor_version=$(echo ${{ steps.patchversion.outputs.mc_patch_version }} | awk -F. '{ print $1"."$2 }')" >> $GITHUB_OUTPUT
- name: Get Details
id: filepath
run: echo "file_path=./build/libs/${{ steps.moddetails.outputs.mod_name }}-${{ steps.moddetails.outputs.mod_version }}.jar" >> $GITHUB_OUTPUT
build:
name: Build and cache
runs-on: ubuntu-latest
needs: [ setup ]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '${{ needs.setup.outputs.java_version }}'
distribution: 'adopt'
cache: 'gradle'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Data Generators
run: ./gradlew rundata
- name: Build
if: always()
run: ./gradlew :build
- name: Cache
uses: actions/cache@v3
with:
path: |
${{ needs.setup.outputs.file_path }}
CHANGELOG.md
key: ${{ github.sha }}
upload:
name: Upload to ModRepo
runs-on: ubuntu-latest
needs: [ setup,build ]
steps:
- name: Restore Cache
uses: actions/cache@v3
with:
path: |
${{ needs.setup.outputs.file_path }}
CHANGELOG.md
key: ${{ github.sha }}
- name: Upload to CurseForge
if: ${{ vars.MODREPO == 'curseforge' || vars.MODREPO == 'both' }}
uses: Kir-Antipov/mc-publish@v3.3
with:
curseforge-id: 353935
curseforge-token: ${{ secrets.curseforge_api }}
files-primary: ${{ needs.setup.outputs.file_path }}
name: ${{ needs.setup.outputs.mod_name }}-${{ needs.setup.outputs.mod_version }}
version: ${{ needs.setup.outputs.mod_version }}
changelog-file: CHANGELOG.md
loaders: |
forge
game-versions: |
${{ needs.setup.outputs.mc_minor_version }}
${{ needs.setup.outputs.mc_patch_version }}
java: |
${{ needs.setup.outputs.java_version }}
- name: Upload to Modrinth
if: ${{ vars.MODREPO == 'modrinth' || vars.MODREPO == 'both' }}
uses: Kir-Antipov/mc-publish@v3.3
with:
modrinth-id: KFQYC1Uy
modrinth-token: ${{ secrets.modrinth_api }}
files-primary: ${{ needs.setup.outputs.file_path }}
name: ${{ needs.setup.outputs.mod_name }}-${{ needs.setup.outputs.mod_version }}
version: ${{ needs.setup.outputs.mod_version }}
changelog-file: CHANGELOG.md
loaders: |
forge
game-versions: |
${{ needs.setup.outputs.mc_minor_version }}
${{ needs.setup.outputs.mc_patch_version }}
java: |
${{ needs.setup.outputs.java_version }}
message:
name: send discord update messaage
runs-on: ubuntu-latest
needs: [ setup,build,upload ]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Read changelog
id: changelog
uses: juliangruber/read-file-action@v1
with:
path: CHANGELOG.md
- name: Discord Webhook Action
uses: tsickert/discord-webhook@v5.3.0
with:
webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }}
username: Project MMO Updates
content: ${{ steps.changelog.outputs.content }}