Skip to content

Commit

Permalink
feat: Add cache and split publish workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Runkang10 committed Oct 20, 2024
1 parent ec25d8f commit 1e99394
Showing 1 changed file with 16 additions and 40 deletions.
56 changes: 16 additions & 40 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,56 +1,32 @@
name: Build and Publish to Modrinth
name: Publish

on:
push:
branches:
- main
workflow_dispatch:

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up SDK 21
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21

- run: chmod +x ./gradlew

- name: Run tests
run: ./gradlew test

build:
runs-on: ubuntu-latest
needs: test

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up SDK 21
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21

- run: chmod +x ./gradlew

- name: Build
run: ./gradlew build

jobs:
publish:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
needs: build

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Cache Gradle
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
gradle-${{ runner.os }}
- name: Set up SDK 21
uses: actions/setup-java@v4
with:
Expand All @@ -60,6 +36,6 @@ jobs:
- run: chmod +x ./gradlew

- name: Publish on Modrinth
run: ./gradlew modrinth
run: ./gradlew modrinth --no-daemon
env:
MODRINTH_SECRET: ${{ secrets.MODRINTH_SECRET }}
MODRINTH_SECRET: ${{ secrets.MODRINTH_SECRET }}

0 comments on commit 1e99394

Please sign in to comment.