Skip to content

Commit

Permalink
Update workflows.
Browse files Browse the repository at this point in the history
  • Loading branch information
fnuecke committed Apr 15, 2024
1 parent a51784e commit aaa78f9
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 34 deletions.
17 changes: 10 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,25 @@ jobs:
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: ${{ matrix.java }}
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- uses: actions/cache@v3

- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: ${{ runner.os }}-gradle-

- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v2
- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build with Gradle
run: ./gradlew build
71 changes: 44 additions & 27 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ name: publish

on:
release:
types: [published]
types: [ published ]

jobs:
build:
name: publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
outputs:
mc_version: ${{ steps.split_tag.outputs.mc_version }}
mod_version: ${{ steps.split_tag.outputs.mod_version }}

steps:
- name: Extract Version from Tag
id: split_tag
run: |
Expand All @@ -20,60 +21,76 @@ jobs:
echo "mod_version=${parts[1]}" >> $GITHUB_OUTPUT
- name: Set up JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- uses: actions/cache@v3

- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: ubuntu-latest-gradle-

- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v2
- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build with Gradle
run: ./gradlew -PmodVersion='${{ steps.split_tag.outputs.mod_version }}' build

- name: Remove extra JARs
- name: Remove shadow JARs
run: |
rm fabric/build/libs/*-dev-shadow.jar
rm forge/build/libs/*-dev-shadow.jar
rm neoforge/build/libs/*-dev-shadow.jar
- name: Add Artifacts to Github Release
uses: alexellis/upload-assets@0.4.0
uses: alexellis/upload-assets@0.4.1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
asset_paths: '["./forge/build/libs/*.jar","./fabric/build/libs/*.jar","./common/build/libs/*-api.jar"]'
asset_paths: '["./fabric/build/libs/*.jar","./forge/build/libs/*.jar","./neoforge/build/libs/*.jar","./common/build/libs/*-api.jar"]'

- name: Publish to Curseforge and Minotaur (Forge)
uses: Kir-Antipov/mc-publish@v3.3
- uses: actions/upload-artifact@v4
name: Upload Artifacts
id: upload-artifacts
with:
name: ${{ github.event.repository.name }}-MC${{ steps.split_tag.outputs.mc_version }}-${{ steps.split_tag.outputs.mod_version }}
version: MC${{ steps.split_tag.outputs.mc_version }}-forge-${{ steps.split_tag.outputs.mod_version }}
java: Java 17
name: jar-files
path: |
./common/build/libs/*-api.jar
./fabric/build/libs/*.jar
./forge/build/libs/*.jar
./neoforge/build/libs/*.jar
retention-days: 1

files: |
forge/build/libs/*.jar
common/build/libs/*-api.jar
publish:
strategy:
matrix:
loader: [ fabric, forge, neoforge ]
runs-on: ubuntu-latest
needs: build

modrinth-token: ${{ secrets.MODRINTH_API_KEY }}
curseforge-token: ${{ secrets.CURSEFORGE_API_KEY }}
steps:
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: jar-files

- name: Publish to Curseforge and Minotaur (Fabric)
- name: Publish (${{ matrix.loader }})
uses: Kir-Antipov/mc-publish@v3.3
with:
name: ${{ github.event.repository.name }}-MC${{ steps.split_tag.outputs.mc_version }}-${{ steps.split_tag.outputs.mod_version }}
version: MC${{ steps.split_tag.outputs.mc_version }}-fabric-${{ steps.split_tag.outputs.mod_version }}
name: ${{ github.event.repository.name }}-MC${{ needs.build.outputs.mc_version }}-${{ needs.build.outputs.mod_version }}
version: MC${{ needs.build.outputs.mc_version }}-${{ matrix.loader }}-${{ needs.build.outputs.mod_version }}
java: Java 17

files: |
fabric/build/libs/*.jar
common/build/libs/*-api.jar
${{ matrix.loader }}/build/libs/*.jar
modrinth-token: ${{ secrets.MODRINTH_API_KEY }}
curseforge-token: ${{ secrets.CURSEFORGE_API_KEY }}

0 comments on commit aaa78f9

Please sign in to comment.