Maven Release #9
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Maven Release | |
'on': | |
release: | |
types: [published] | |
jobs: | |
publish: | |
name: Build and Upload JARs | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Java | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '21' # Make sure to set the correct Java version for your project | |
distribution: temurin | |
- name: Set maven project version | |
run: mvn -B versions:set -DnewVersion=${{ github.event.release.tag_name }} -DgenerateBackupPoms=false | |
- name: Build and package Maven project | |
run: mvn clean package -DskipTests | |
- name: Upload to release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: target/MinecraftServerAPI-${{ github.event.release.tag_name }}.jar | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Upload to Modrinth | |
run: | | |
# Fetch and format the changelog | |
formatted_changelog=$(echo "${{ github.event.release.body }}" | sed ':a;N;$!ba;s/\n/\\n/g' | sed 's/"/\\"/g') | |
# Perform the curl request with the formatted changelog | |
curl -X POST https://api.modrinth.com/v2/version \ | |
-H "Authorization: Bearer ${{ secrets.MODRINTH_TOKEN }}" \ | |
-H "Content-Type: multipart/form-data" \ | |
-F "data={\"name\": \"${{ github.event.release.tag_name }}\", \"version_number\": \"${{ github.event.release.tag_name }}\", \"changelog\": \"$formatted_changelog\", \"dependencies\": [], \"game_versions\": [\"1.9\", \"1.9.1\", \"1.9.2\", \"1.9.3\", \"1.9.4\", \"1.10\", \"1.10.2\", \"1.11\", \"1.11.1\", \"1.11.2\", \"1.12\", \"1.12.1\", \"1.12.2\", \"1.13\", \"1.13.2\", \"1.14\", \"1.14.1\", \"1.14.2\", \"1.14.3\", \"1.14.4\", \"1.15\", \"1.15.1\", \"1.15.2\", \"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\", \"1.20.3\", \"1.20.4\", \"1.20.5\", \"1.20.6\", \"1.21\", \"1.21.1\"], \"version_type\": \"release\", \"loaders\": [\"fabric\", \"forge\", \"spigot\"], \"featured\": true, \"status\": \"listed\", \"requested_status\": \"listed\"}" \ | |
-F "file=@target/MinecraftServerAPI-${{ github.event.release.tag_name }}.jar" \ | |
-F "file_parts=file" \ | |
-F "primary_file=file" | |
env: | |
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} | |