Skip to content

v1.9.6

v1.9.6 #11

name: Build and release plugin to CurseForge and Modrinth
on:
push:
tags:
- 'v*'
workflow_dispatch:
env:
CURSEFORGE_PROJECT_ID: ${{ vars.CURSEFORGE_PROJECT_ID }}
MODRINTH_PROJECT_ID: ${{ vars.MODRINTH_PROJECT_ID }}
jobs:
build:
runs-on: ubuntu-latest
outputs:
jar-path: ${{ steps.jar.outputs.jar-path }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn -B package --file pom.xml
- name: Get JAR file path
id: jar
run: |
JAR_NAME=$(ls target/*.jar | grep -v 'original' | head -n 1)
echo "jar-path=$JAR_NAME" >> $GITHUB_OUTPUT
- name: Upload JAR artifact
uses: actions/upload-artifact@v4
with:
name: plugin-jar
path: ${{ steps.jar.outputs.jar-path }}
generate-changelog:
runs-on: ubuntu-latest
needs: build
outputs:
changelog: ${{ steps.changelog.outputs.release-notes }}
release_type: ${{ steps.release-type.outputs.release_type }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Generate Changelog from commits
id: changelog
uses: johnyherangi/create-release-notes@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
format: "- {{subject}}"
- name: Determine release type
id: release-type
run: |
TAG_NAME=${GITHUB_REF#refs/tags/}
echo "Tag is: $TAG_NAME"
if echo "$TAG_NAME" | grep -iq "release"; then
echo "release_type=release" >> $GITHUB_OUTPUT
else
echo "release_type=beta" >> $GITHUB_OUTPUT
fi
publish:
runs-on: ubuntu-latest
needs: [build, generate-changelog]
steps:
- name: Download JAR artifact
uses: actions/download-artifact@v4
with:
name: plugin-jar
path: ./target
- name: Extract version string
id: version
run: |
TAG_NAME=${GITHUB_REF#refs/tags/}
CLEAN_VERSION=$(echo "$TAG_NAME" | grep -oE '[0-9]+(\.[0-9]+)*(-[A-Za-z0-9]+)?')
echo "version=$CLEAN_VERSION" >> "$GITHUB_OUTPUT"
- name: Upload to Modrinth
uses: cloudnode-pro/modrinth-publish@v2.1.2
with:
token: ${{ secrets.MODRINTH_TOKEN }}
project: ${{ env.MODRINTH_PROJECT_ID }}
name: BasicHomes ${{ steps.version.outputs.version }}
version: ${{ steps.version.outputs.version }}
changelog: ${{ needs.generate-changelog.outputs.changelog }}
files: ${{ needs.build.outputs.jar-path }}
game-versions: '[ "1.21" ]'
loaders: '[ "bukkit", "spigot" ]'
status: listed
- name: Upload to CurseForge
uses: itsmeow/curseforge-upload@v3
with:
token: ${{ secrets.CURSEFORGE_TOKEN }}
project_id: ${{ env.CURSEFORGE_PROJECT_ID }}
game_endpoint: minecraft
file_path: ${{ needs.build.outputs.jar-path }}
changelog: ${{ needs.generate-changelog.outputs.changelog }}
changelog_type: markdown
release_type: ${{ needs.generate-changelog.outputs.release_type }}