|
| 1 | +name: Publish to Modrinth and GitHub Releases |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [published] |
| 6 | + |
| 7 | +jobs: |
| 8 | + build: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + outputs: |
| 11 | + version: ${{ steps.get_version.outputs.version }} |
| 12 | + steps: |
| 13 | + - name: Checkout repository |
| 14 | + uses: actions/checkout@v4 |
| 15 | + |
| 16 | + - name: Set up JDK |
| 17 | + uses: actions/setup-java@v4 |
| 18 | + with: |
| 19 | + distribution: 'temurin' |
| 20 | + java-version: '21' |
| 21 | + cache: 'maven' |
| 22 | + |
| 23 | + - name: Cache Maven repository |
| 24 | + uses: actions/cache@v3 |
| 25 | + with: |
| 26 | + path: ~/.m2 |
| 27 | + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} |
| 28 | + restore-keys: | |
| 29 | + ${{ runner.os }}-maven- |
| 30 | +
|
| 31 | + - name: Get release version |
| 32 | + id: get_version |
| 33 | + run: echo "version=${{ github.event.release.tag_name }}" >> $GITHUB_ENV |
| 34 | + |
| 35 | + - name: Set version from release tag |
| 36 | + run: mvn -B versions:set -DnewVersion=${{ github.event.release.tag_name }} -DgenerateBackupPoms=false |
| 37 | + |
| 38 | + - name: Build with Maven |
| 39 | + run: mvn -B clean package |
| 40 | + |
| 41 | + - name: Upload build artifact |
| 42 | + uses: actions/upload-artifact@v4 |
| 43 | + with: |
| 44 | + name: ServerLinksZ-jar |
| 45 | + path: target/ServerLinksZ-${{ github.event.release.tag_name }}.jar |
| 46 | + |
| 47 | + upload_release_asset: |
| 48 | + needs: build |
| 49 | + runs-on: ubuntu-latest |
| 50 | + steps: |
| 51 | + - name: Download build artifact |
| 52 | + uses: actions/download-artifact@v4 |
| 53 | + with: |
| 54 | + name: ServerLinksZ-jar |
| 55 | + path: target/ |
| 56 | + |
| 57 | + - name: Upload JAR to GitHub Release |
| 58 | + uses: softprops/action-gh-release@v2 |
| 59 | + with: |
| 60 | + files: target/ServerLinksZ-${{ github.event.release.tag_name }}.jar |
| 61 | + body: ${{ github.event.release.body }} |
| 62 | + |
| 63 | + publish_modrinth: |
| 64 | + needs: build |
| 65 | + runs-on: ubuntu-latest |
| 66 | + steps: |
| 67 | + - name: Download build artifact |
| 68 | + uses: actions/download-artifact@v4 |
| 69 | + with: |
| 70 | + name: ServerLinksZ-jar |
| 71 | + path: target/ |
| 72 | + |
| 73 | + - name: Publish to Modrinth |
| 74 | + uses: cloudnode-pro/modrinth-publish@v2 |
| 75 | + with: |
| 76 | + token: ${{ secrets.MODRINTH_TOKEN }} |
| 77 | + project: 'iR9qgF1M' |
| 78 | + version: ${{ github.event.release.tag_name }} |
| 79 | + name: 'ServerLinksZ ${{ github.event.release.tag_name }}' |
| 80 | + changelog: ${{ github.event.release.body }} |
| 81 | + files: '["target/ServerLinksZ-${{ github.event.release.tag_name }}.jar"]' |
| 82 | + loaders: |- |
| 83 | + paper |
| 84 | + purpur |
| 85 | + game-versions: |- |
| 86 | + 1.21.x |
| 87 | + status: 'listed' |
| 88 | + channel: 'release' |
0 commit comments