Release to CurseForge and Modrinth #50
This file contains hidden or 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: Release to CurseForge and Modrinth | |
| on: | |
| # Only trigger manually to avoid duplicate runs | |
| # GitHub CLI releases don't reliably trigger workflows anyway | |
| workflow_dispatch: | |
| inputs: | |
| release_tag: | |
| description: 'Release tag to process (e.g., v1.20.4)' | |
| required: true | |
| type: string | |
| jobs: | |
| build-and-release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| with: | |
| # Checkout the specified tag | |
| ref: ${{ github.event.inputs.release_tag }} | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v3 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| cache: 'maven' | |
| - name: Build with Maven | |
| run: mvn clean package -DskipTests | |
| - name: Get artifact info | |
| id: artifact | |
| run: | | |
| # Use the input tag | |
| VERSION="${{ github.event.inputs.release_tag }}" | |
| VERSION="${VERSION#v}" # Remove 'v' prefix if present | |
| echo "jar_path=$(find target/ -name 'MinecraftServerAPI-*.jar' | head -n 1)" >> $GITHUB_OUTPUT | |
| echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
| echo "Processing version: ${VERSION}" | |
| - name: Extract game version from branch or tag | |
| id: game_version | |
| run: | | |
| # Get the version for game-versions field | |
| VERSION="${{ steps.artifact.outputs.version }}" | |
| # Check if version contains 'x' (wildcard) | |
| if [[ "$VERSION" == *".x"* ]]; then | |
| # It's a wildcard version like 1.21.x | |
| # Extract base version (e.g., 1.21 from 1.21.x) | |
| BASE_VERSION=$(echo "$VERSION" | sed 's/\.x$//' | grep -oE '[0-9]+\.[0-9]+') | |
| # Calculate next minor version for upper bound | |
| MAJOR=$(echo "$BASE_VERSION" | cut -d. -f1) | |
| MINOR=$(echo "$BASE_VERSION" | cut -d. -f2) | |
| NEXT_MINOR=$((MINOR + 1)) | |
| NEXT_VERSION="${MAJOR}.${NEXT_MINOR}" | |
| # Create version range: [1.20,1.21) | |
| # [1.20 = includes 1.20 and higher | |
| # ,1.21) = but excludes 1.21 and higher | |
| # Result: 1.20, 1.20.1, 1.20.2, ..., 1.20.99 (all 1.20.x versions) | |
| VERSIONS="[${BASE_VERSION},${NEXT_VERSION})" | |
| echo "minecraft_versions=${VERSIONS}" >> $GITHUB_OUTPUT | |
| echo "Minecraft versions (wildcard): ${VERSIONS} (includes ALL ${BASE_VERSION}.x versions including ${BASE_VERSION} itself)" | |
| else | |
| # It's a specific version like 1.21.4 or 1.21 | |
| MC_VERSION=$(echo "$VERSION" | grep -oE '[0-9]+\.[0-9]+(\.[0-9]+)?') | |
| # Just use the exact version - 1.21 is 1.21, 1.21.4 is 1.21.4 | |
| echo "minecraft_versions=${MC_VERSION}" >> $GITHUB_OUTPUT | |
| echo "Minecraft version: ${MC_VERSION} (exact)" | |
| fi | |
| - name: Upload to Modrinth & Curseforge | |
| uses: Kir-Antipov/mc-publish@v3.3 | |
| with: | |
| modrinth-id: H4i6sdRk | |
| modrinth-token: ${{ secrets.MODRINTH_TOKEN }} | |
| curseforge-id: 1101540 | |
| curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }} | |
| files: ${{ steps.artifact.outputs.jar_path }} | |
| name: MinecraftServerAPI ${{ steps.artifact.outputs.version }} | |
| version: msa-${{ steps.artifact.outputs.version }} | |
| version-type: release | |
| game-versions: | | |
| ${{ steps.game_version.outputs.minecraft_versions }} | |
| loaders: | | |
| paper | |
| spigot | |
| bukkit | |
| changelog: | | |
| ## MinecraftServerAPI v${{ steps.artifact.outputs.version }} | |
| ### Changes | |
| - Rebased on latest master branch | |
| - Includes all current features and bugfixes | |
| ### Minecraft Version | |
| Supports Minecraft ${{ steps.artifact.outputs.version }} | |
| ### Installation | |
| Download the JAR file and place it in your Minecraft server's `plugins` folder. | |
| For full documentation, see: https://github.com/${{ github.repository }} |