-
Notifications
You must be signed in to change notification settings - Fork 0
158 lines (156 loc) · 5.64 KB
/
upload.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
name: Build and Uploading
on:
push:
branches:
- main
jobs:
check-commit:
runs-on: ubuntu-latest
steps:
- name: "Match commit message"
id: match
uses: kaisugi/[email protected]
with:
text: ${{ github.event.head_commit.message }}
regex: '[bB]ump.*?(\d+(\.\d+)*)'
- name: "Exit if no match"
if: ${{ steps.match.outputs.group1 == '' }}
run: |
echo 'Not a new version.' > $GITHUB_STEP_SUMMARY
exit 1
- name: "Checking out"
uses: actions/checkout@v3
- name: "List files"
run: ls -R
- name: "Extract changelog"
id: extract-changelog
uses: sean0x42/markdown-extract@v2
with:
file: CHANGELOG.md
pattern: ${{ steps.match.outputs.group1 }}
- name: "Summary"
run: |
echo '# Version' >> $GITHUB_STEP_SUMMARY
echo '## Changelog' >> $GITHUB_STEP_SUMMARY
echo '${{ steps.extract-changelog.outputs.markdown }}' >> $GITHUB_STEP_SUMMARY
outputs:
new_ver: ${{ steps.match.outputs.group1 }}
changelog: ${{ steps.extract-changelog.outputs.markdown }}
build:
needs:
- check-commit
runs-on: ubuntu-latest
if: ${{ needs.check-commit.outputs.new_ver != '' }}
steps:
- name: "Display version"
run: echo 'Compiling for version ${{ needs.check-commit.outputs.new_ver }}'
- name: "Checking out"
uses: actions/checkout@v3
- name: "Set up java"
uses: actions/setup-java@v3
with:
distribution: 'corretto' # See 'Supported distributions' for available options
java-version: '17'
cache: maven
- name: "Build the jar"
run: mvn --batch-mode --update-snapshots verify
- name: "Upload artifact"
uses: actions/upload-artifact@v3
with:
name: ${{ needs.check-commit.outputs.new_ver }}
path: |
**/*.jar
!**/original-*.jar
release:
needs:
- check-commit
- build
runs-on: ubuntu-latest
if: ${{ needs.check-commit.outputs.new_ver != '' }}
steps:
- uses: mukunku/[email protected]
id: check_exists
with:
tag: v${{ needs.check-commit.outputs.new_ver }}
- name: "Exit if release exists"
run: exit 1
if: steps.check_exists.outputs.exists == 'true'
- name: "Downloading built jar"
uses: actions/download-artifact@v3
with:
name: ${{ needs.check-commit.outputs.new_ver }}
- name: "Display structure of downloaded files"
run: ls -R
- name: "Create Release"
id: create_release
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
tag_name: v${{ needs.check-commit.outputs.new_ver }}
name: Release v${{ needs.check-commit.outputs.new_ver }}
body: ${{ needs.check-commit.outputs.changelog }}
draft: false
prerelease: false
files: './target/*.jar'
fail_on_unmatched_files: true
- name: "Summary"
run: |
echo '## GitHub Release' >> $GITHUB_STEP_SUMMARY
echo 'Release can be found at ${{ steps.create_release.outputs.url }}'
upload-curseforge:
needs:
- check-commit
- build
runs-on: ubuntu-latest
if: ${{ needs.check-commit.outputs.new_ver != '' }}
steps:
- name: "Downloading built jar"
uses: actions/download-artifact@v3
with:
name: ${{ needs.check-commit.outputs.new_ver }}
- name: "Display structure of downloaded files"
run: ls -R
- id: find_jar
run: JAR_LOC="$(find * -name '*.jar')" && echo "jar_loc=$JAR_LOC" >> $GITHUB_OUTPUT
- name: "Upload to CurseForge"
uses: itsmeow/[email protected]
with:
token: ${{ secrets.CURSEFORGE_TOKEN }}
project_id: 933999
game_endpoint: "minecraft"
file_path: ${{ steps.find_jar.outputs.jar_loc }}
changelog: ${{ needs.check-commit.outputs.changelog }}
game_versions: 1.16.5,1.17,1.18,1.18.1,1.18.2,1.19,1.19.1,1.19.2,1.19.3,1.19.4,1.20,1.20.1,1.20.2
upload-modrinth:
needs:
- check-commit
- build
runs-on: ubuntu-latest
if: ${{ needs.check-commit.outputs.new_ver != '' }}
steps:
- name: "Downloading built jar"
uses: actions/download-artifact@v3
with:
name: ${{ needs.check-commit.outputs.new_ver }}
- name: "Display structure of downloaded files"
run: ls -R
- id: find_jar
run: JAR_LOC="$(find * -name '*.jar')" && echo "jar_loc=$JAR_LOC" >> $GITHUB_OUTPUT
- name: "Upload to Modrinth"
uses: RubixDev/modrinth-upload@v1
id: upload
with:
token: ${{ secrets.MODRINTH_TOKEN }}
file_path: ${{ steps.find_jar.outputs.jar_loc }}
name: v${{ needs.check-commit.outputs.new_ver }}
version: ${{ needs.check-commit.outputs.new_ver }}
changelog: ${{ needs.check-commit.outputs.changelog }}
game_versions: 1.16,1.16.1,1.16.2,1.16.3,1.16.4,1.16.5,1.17,1.17.1,1.18,1.18.1,1.18.2,1.19,1.19.1,1.19.2,1.19.3,1.19.4,1.20,1.20.1,1.20.2
release_type: release
loaders: bukkit,spigot,paper
featured: true
project_id: XOp04Yi2
- name: "Summary"
run: |
echo '## Modrinth Release' >> $GITHUB_STEP_SUMMARY
echo 'Release can be found at https://modrinth.com/plugin/${{ steps.upload.with.project_id }}/version/${{ steps.upload.outputs.id }}' >> $GITHUB_STEP_SUMMARY