From c82c425a8474c343aecc4436ec44342bd38c4fcb Mon Sep 17 00:00:00 2001 From: Half_nothing Date: Wed, 11 Sep 2024 19:46:40 +0800 Subject: [PATCH] ci: Add auto publish action * For auto publish to Modrinth and CurseForge, MODRINTH_TOKEN and CF_API_TOKEN are required --- .github/workflows/build.yml | 42 ++++++++++++++-------------- .github/workflows/check_style.yml | 24 ---------------- .github/workflows/release.yml | 46 +++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 45 deletions(-) delete mode 100644 .github/workflows/check_style.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e6cb5e0..29d2179 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,29 +2,29 @@ name: build on: [ push, pull_request ] jobs: - build: - runs-on: ubuntu-latest + build: + runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 + steps: + - uses: actions/checkout@v4 - - name: Set up JDK 21 - uses: actions/setup-java@v4 - with: - java-version: '21' - distribution: 'liberica' - cache: 'gradle' + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + java-version: '21' + distribution: 'liberica' + cache: 'gradle' - - name: Setup Gradle - uses: gradle/actions/setup-gradle@v3 - with: - gradle-version: 8.8 + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + with: + gradle-version: 8.8 - - name: Build artifacts - run: gradle build + - name: Build artifacts + run: gradle build - - name: Upload build artifacts - uses: actions/upload-artifact@v4 - with: - name: build-artifacts - path: build/libs + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + with: + name: build-artifacts + path: build/libs diff --git a/.github/workflows/check_style.yml b/.github/workflows/check_style.yml deleted file mode 100644 index 279e6a5..0000000 --- a/.github/workflows/check_style.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: check_style -on: [ push, pull_request ] - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Set up JDK 21 - uses: actions/setup-java@v4 - with: - java-version: '21' - distribution: 'liberica' - cache: 'gradle' - - - name: Setup Gradle - uses: gradle/actions/setup-gradle@v3 - with: - gradle-version: 8.8 - - - name: Build artifacts - run: gradle detekt diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..724a172 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,46 @@ +name: Release + +on: + release: + types: [ published ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + java-version: '21' + distribution: 'liberica' + cache: 'gradle' + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + with: + gradle-version: 8.8 + + - name: Build artifacts + run: gradle build + + - name: Upload assets to GitHub, Modrinth and CurseForge + uses: Kir-Antipov/mc-publish@v3.3 + with: + modrinth-id: QuPbmyCQ + modrinth-featured: false + modrinth-token: ${{ secrets.MODRINTH_TOKEN }} + + curseforge-id: 945501 + curseforge-token: ${{ secrets.CF_API_TOKEN }} + + github-token: ${{ secrets.GITHUB_TOKEN }} + + loaders: | + fabric + + files: | + build/libs/!(*-@(dev-all|sources)).jar + build/libs/*-@(dev-all|sources).jar