CI/CD Now uploads to modrinth #4
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 Build | |
| on: | |
| push: | |
| branches: | |
| - master | |
| # Suppress Node.js 20 deprecation warnings by explicitly opting into Node 24 | |
| env: | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: 📦 Checkout Code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Required to generate a changelog from git history | |
| - name: ☕ Set up Java 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '21' | |
| cache: 'maven' | |
| - name: 🏷 Get and Clean Version from pom.xml | |
| id: version | |
| run: | | |
| RAW_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) | |
| CLEAN_VERSION=$(echo $RAW_VERSION | cut -d'-' -f1) | |
| echo "VERSION=$CLEAN_VERSION" >> $GITHUB_ENV | |
| echo "version=$CLEAN_VERSION" >> $GITHUB_OUTPUT | |
| - name: 📝 Generate Changelog | |
| id: changelog | |
| run: | | |
| # Gets commits between the last two tags, or all commits if no tags exist | |
| # Formats as: hash message - author | |
| CHANGELOG=$(git log --pretty=format:"%h %s - %an" -n 10) | |
| echo "changelog<<EOF" >> $GITHUB_OUTPUT | |
| echo "$CHANGELOG" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| - name: 🛠 Build Production JAR | |
| run: | | |
| mvn clean package -Drevision=${{ env.VERSION }} | |
| - name: 📦 Prepare Release Artifacts | |
| run: | | |
| mkdir -p dist | |
| JAR=$(find target -name "AutoPickup-${{ env.VERSION }}.jar" | head -n1) | |
| if [ -z "$JAR" ]; then | |
| echo "❌ JAR not found" | |
| exit 1 | |
| fi | |
| cp "$JAR" "dist/AutoPickup-${{ env.VERSION }}.jar" | |
| - name: 📥 Upload to Modrinth | |
| uses: modrinth/minotaur@v3 | |
| with: | |
| token: ${{ secrets.MODRINTH_TOKEN }} # You must add this to GitHub Secrets | |
| project-id: "oB3hT7d7" # Replace with your Modrinth Project ID or Slug | |
| version-number: ${{ env.VERSION }} | |
| version-name: "AutoPickup ${{ env.VERSION }}" | |
| version-type: "release" | |
| changelog: ${{ steps.changelog.outputs.changelog }} | |
| loaders: | | |
| paper | |
| purpur | |
| spigot | |
| game-versions: | | |
| 1.21 | |
| 1.21.1 | |
| files: dist/*.jar | |
| - name: 📥 Upload Artifact to GitHub | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: AutoPickup-${{ env.VERSION }} | |
| path: dist/*.jar |