Publish to Modrinth and GitHub Releases #8
Workflow file for this run
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: Publish to Modrinth and GitHub Releases | |
| on: | |
| release: | |
| types: [published] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.get_version.outputs.version }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '21' | |
| cache: 'gradle' | |
| - name: Cache Gradle packages | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ~/.gradle/caches | |
| ~/.gradle/wrapper | |
| key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
| restore-keys: | | |
| ${{ runner.os }}-gradle- | |
| - name: Get release version | |
| id: get_version | |
| run: echo "version=${{ github.event.release.tag_name }}" >> $GITHUB_ENV | |
| - name: Set version from release tag | |
| run: | | |
| sed -i "s/^version = .*/version = '${{ github.event.release.tag_name }}'/" gradle.properties | |
| - name: Grant execute permission for Gradle | |
| run: chmod +x ./gradlew | |
| - name: Build with Gradle | |
| run: ./gradlew build | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: TimberZ-jars | |
| path: | | |
| build/libs/TimberZ-${{ github.event.release.tag_name }}-1.21.4.jar | |
| build/libs/TimberZ-${{ github.event.release.tag_name }}-1.21.9.jar | |
| upload_release_asset: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: TimberZ-jars | |
| path: build/libs/ | |
| - name: Upload JARs to GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: | | |
| build/libs/TimberZ-${{ github.event.release.tag_name }}-1.21.4.jar | |
| build/libs/TimberZ-${{ github.event.release.tag_name }}-1.21.9.jar | |
| body: ${{ github.event.release.body }} | |
| publish_modrinth: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: TimberZ-jars | |
| path: build/libs/ | |
| - name: Publish 1.21.4 JAR to Modrinth | |
| uses: cloudnode-pro/modrinth-publish@v2 | |
| with: | |
| token: ${{ secrets.MODRINTH_TOKEN }} | |
| project: 'hjNMOOnF' | |
| version: ${{ github.event.release.tag_name }} | |
| name: 'TimberZ ${{ github.event.release.tag_name }} (1.21.4-1.21.8)' | |
| changelog: ${{ github.event.release.body }} | |
| files: '["build/libs/TimberZ-${{ github.event.release.tag_name }}-1.21.4.jar"]' | |
| loaders: |- | |
| paper | |
| purpur | |
| game-versions: |- | |
| 1.21.4 | |
| 1.21.5 | |
| 1.21.6 | |
| 1.21.7 | |
| 1.21.8 | |
| status: 'listed' | |
| channel: 'release' | |
| - name: Publish 1.21.9 JAR to Modrinth | |
| uses: cloudnode-pro/modrinth-publish@v2 | |
| with: | |
| token: ${{ secrets.MODRINTH_TOKEN }} | |
| project: 'hjNMOOnF' | |
| version: ${{ github.event.release.tag_name }} | |
| name: 'TimberZ ${{ github.event.release.tag_name }} (>1.21.9)' | |
| changelog: ${{ github.event.release.body }} | |
| files: '["build/libs/TimberZ-${{ github.event.release.tag_name }}-1.21.9.jar"]' | |
| loaders: |- | |
| paper | |
| purpur | |
| game-versions: |- | |
| 1.21.9 | |
| 1.21.10 | |
| status: 'listed' | |
| channel: 'release' |