From fc6f1174b1b924d604204461354109abfe24eb50 Mon Sep 17 00:00:00 2001 From: KrLite <68179735+KrLite@users.noreply.github.com> Date: Fri, 5 Apr 2024 09:47:32 +0800 Subject: [PATCH] workflows --- .github/workflows/build.yml | 45 +++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 34 ++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..8fc2947 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,45 @@ +name: Build + +on: [ pull_request, push, workflow_dispatch ] + +jobs: + Build: + runs-on: ubuntu-22.04 + + steps: + - uses: actions/checkout@v3 + - name: Get github short hash + id: github_short_hash + run: echo "result=$(git rev-parse --short "${{ github.sha }}")" >> $GITHUB_OUTPUT + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: 17 + - name: Cache + uses: actions/cache@v2 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + .gradle + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', 'build.gradle') }} + - name: Build with Gradle + run: | + chmod +x gradlew + ./gradlew build + - name: Upload artifacts (fabric) + uses: actions/upload-artifact@v3 + with: + name: Artifacts-fabric + path: ${{ github.workspace }}/fabric/build/libs + - name: Upload artifacts (forge) + uses: actions/upload-artifact@v3 + with: + name: Artifacts-forge + path: ${{ github.workspace }}/forge/build/libs + - name: Upload artifacts (neoforge) + uses: actions/upload-artifact@v3 + with: + name: Artifacts-forge + path: ${{ github.workspace }}/neoforge/build/libs diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..1b7232c --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,34 @@ +name: Publish Release + +on: [ release, workflow_dispatch ] + +permissions: + contents: write + +jobs: + Publish: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 20 + uses: actions/setup-java@v3 + with: + distribution: 'adopt' + java-version: 20 + - name: Cache + uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + .gradle + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts*', '**/*.gradle*', '**/gradle-wrapper.properties', 'build.gradle.kts', 'build.gradle') }} + - uses: gradle/wrapper-validation-action@v1 + - run: | + chmod +x gradlew + ./gradlew build publishMod --stacktrace -Porg.gradle.parallel.threads=4 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} + CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }}