Skip to content

Commit a94faf6

Browse files
committed
feat: new workflow
1 parent 1db770b commit a94faf6

File tree

1 file changed

+18
-84
lines changed

1 file changed

+18
-84
lines changed

.github/workflows/build-and-publish.yml

Lines changed: 18 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@ env:
1111
MODRINTH_PROJECT_ID: ${{ vars.MODRINTH_PROJECT_ID }}
1212

1313
jobs:
14-
build:
14+
build-and-publish:
1515
runs-on: ubuntu-latest
16-
outputs:
17-
jar-path: ${{ steps.jar.outputs.jar-path }}
18-
16+
permissions:
17+
contents: write
1918
steps:
2019
- name: Checkout Code
2120
uses: actions/checkout@v4
@@ -30,84 +29,19 @@ jobs:
3029
- name: Build with Maven
3130
run: mvn -B package --file pom.xml
3231

33-
- name: Get JAR file path
34-
id: jar
35-
run: |
36-
JAR_NAME=$(ls target/*.jar | grep -v 'original' | head -n 1)
37-
echo "jar-path=$JAR_NAME" >> $GITHUB_OUTPUT
38-
- name: Upload JAR artifact
39-
uses: actions/upload-artifact@v4
40-
with:
41-
name: plugin-jar
42-
path: ${{ steps.jar.outputs.jar-path }}
43-
44-
45-
generate-changelog:
46-
runs-on: ubuntu-latest
47-
needs: build
48-
outputs:
49-
changelog: ${{ steps.read-changelog.outputs.changelog }}
50-
release_type: ${{ steps.release-type.outputs.release_type }}
51-
52-
steps:
53-
- name: Checkout Code
54-
uses: actions/checkout@v4
55-
56-
- name: Read CHANGELOG.md
57-
id: read-changelog
58-
run: |
59-
# Read file, escape % and newlines for GitHub Actions
60-
CONTENT=$(cat CHANGELOG.md | sed 's/%/%25/g' | sed ':a;N;$!ba;s/\n/%0A/g')
61-
echo "changelog=$CONTENT" >> $GITHUB_OUTPUT
62-
63-
- name: Determine release type
64-
id: release-type
65-
run: |
66-
TAG_NAME=${GITHUB_REF#refs/tags/}
67-
echo "Tag is: $TAG_NAME"
68-
if echo "$TAG_NAME" | grep -iq "release"; then
69-
echo "release_type=release" >> $GITHUB_OUTPUT
70-
else
71-
echo "release_type=beta" >> $GITHUB_OUTPUT
72-
fi
73-
publish:
74-
runs-on: ubuntu-latest
75-
needs: [build, generate-changelog]
76-
77-
steps:
78-
- name: Download JAR artifact
79-
uses: actions/download-artifact@v4
80-
with:
81-
name: plugin-jar
82-
path: ./target
83-
84-
- name: Extract version string
85-
id: version
86-
run: |
87-
TAG_NAME=${GITHUB_REF#refs/tags/}
88-
CLEAN_VERSION=$(echo "$TAG_NAME" | grep -oE '[0-9]+(\.[0-9]+)*(-[A-Za-z0-9]+)?')
89-
echo "version=$CLEAN_VERSION" >> "$GITHUB_OUTPUT"
90-
91-
- name: Upload to Modrinth
92-
uses: cloudnode-pro/modrinth-publish@v2.1.2
93-
with:
94-
token: ${{ secrets.MODRINTH_TOKEN }}
95-
project: ${{ env.MODRINTH_PROJECT_ID }}
96-
name: BasicHomes ${{ steps.version.outputs.version }}
97-
version: ${{ steps.version.outputs.version }}
98-
changelog: ${{ needs.generate-changelog.outputs.changelog }}
99-
files: ${{ needs.build.outputs.jar-path }}
100-
game-versions: '[ "1.21" ]'
101-
loaders: '[ "bukkit", "spigot" ]'
102-
status: listed
103-
104-
- name: Upload to CurseForge
105-
uses: itsmeow/curseforge-upload@v3
32+
- name: Publish to Modrinth & CurseForge
33+
uses: Kira-NT/mc-publish@v3
10634
with:
107-
token: ${{ secrets.CURSEFORGE_TOKEN }}
108-
project_id: ${{ env.CURSEFORGE_PROJECT_ID }}
109-
game_endpoint: minecraft
110-
file_path: ${{ needs.build.outputs.jar-path }}
111-
changelog: ${{ needs.generate-changelog.outputs.changelog }}
112-
changelog_type: markdown
113-
release_type: ${{ needs.generate-changelog.outputs.release_type }}
35+
modrinth-id: ${{ env.MODRINTH_PROJECT_ID }}
36+
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
37+
curseforge-id: ${{ env.CURSEFORGE_PROJECT_ID }}
38+
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
39+
files: target/*.jar
40+
changelog-file: CHANGELOG.md
41+
game-versions: |
42+
1.21
43+
loaders: |
44+
bukkit
45+
spigot
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)