Distribute JARs #50
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: Distribute JARs | |
| on: | |
| release: | |
| types: [published] | |
| jobs: | |
| build: | |
| runs-on: "ubuntu-latest" | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Java | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: corretto | |
| java-version: 21 | |
| - name: Cache Gradle | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.gradle/caches | |
| ~/.gradle/wrapper/ | |
| key: ${{ runner.os }}-gradle | |
| restore-keys: | | |
| ${{ runner.os }}-gradle | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v3 | |
| with: | |
| gradle-version: "wrapper" | |
| - name: Build JARs | |
| uses: Wandalen/wretry.action@master | |
| with: | |
| command: "gradle build" | |
| attempt_limit: 3 | |
| - name: Upload Built JARs | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: built-jars | |
| path: | | |
| ./versions/**/build/libs/*.jar | |
| set-matrix: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| game_versions: ${{ steps.set-matrix.outputs.game_versions }} | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| - id: set-matrix | |
| run: | | |
| BRANCH="${{ github.event.release.target_commitish }}" | |
| if [ -f .github/targets.json ]; then | |
| if jq -e --arg branch "$BRANCH" 'has($branch)' .github/targets.json > /dev/null; then | |
| matrix=$(jq -c --arg branch "$BRANCH" '.[$branch]' .github/targets.json) | |
| echo "game_versions=$matrix" >> $GITHUB_OUTPUT | |
| else | |
| echo "::error ::Branch '$BRANCH' is not supported for distribution!" | |
| exit 1 | |
| fi | |
| else | |
| echo "::error ::.github/targets.json is missing!" | |
| exit 1 | |
| fi | |
| distribute: | |
| needs: [ build, set-matrix ] | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| game_version: ${{ fromJson(needs.set-matrix.outputs.game_versions) }} | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| - name: Download Built JARs | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: built-jars | |
| path: ./versions | |
| - name: Determine Version Type | |
| id: versioning | |
| run: | | |
| if [[ "${{ github.event.release.target_commitish }}" == "lts" ]]; then | |
| echo "type=release" >> $GITHUB_OUTPUT | |
| else | |
| echo "type=beta" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Publish to Modrinth, CurseForge, etc. | |
| uses: Kir-Antipov/mc-publish@v3.3 | |
| with: | |
| files: | | |
| versions/${{ matrix.game_version }}/build/libs/!(*-@(dev|sources|javadoc)).jar | |
| versions/${{ matrix.game_version }}/build/libs/*-@(dev|sources|javadoc).jar | |
| version: ${{ github.ref_name }}+${{ matrix.game_version }} | |
| version-type: ${{ steps.versioning.outputs.type }} | |
| modrinth-id: ${{ vars.MODRINTH_ID }} | |
| modrinth-token: ${{ secrets.MODRINTH_TOKEN }} | |
| curseforge-id: ${{ vars.CURSEFORGE_ID }} | |
| curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }} | |
| github-token: ${{ secrets.CLASSIC_GITHUB_TOKEN }} |