From 7ac1c3d66d1f56acafb6866d747f056d0d229917 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Mon, 4 Nov 2024 21:36:53 +0100 Subject: [PATCH] try a cool github actions workflow for publishing --- .github/workflows/{main.yml => build.yml} | 8 +++--- .github/workflows/release.yml | 32 +++++++++++++++++++++++ build.gradle | 28 ++++++++++++++++++++ gradle.properties | 1 + 4 files changed, 65 insertions(+), 4 deletions(-) rename .github/workflows/{main.yml => build.yml} (82%) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/main.yml b/.github/workflows/build.yml similarity index 82% rename from .github/workflows/main.yml rename to .github/workflows/build.yml index 449eaf4f..c57f9c11 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/build.yml @@ -3,12 +3,12 @@ jobs: build: runs-on: ubuntu-latest steps: - - name: Clone repository + - name: Clone Repository uses: actions/checkout@v4 - name: Setup Java uses: actions/setup-java@v4 with: - java-version: '17' + java-version: '21' distribution: 'temurin' - name: Cache uses: actions/cache@v4 @@ -16,7 +16,7 @@ jobs: path: | ~/.gradle/caches ~/.gradle/wrapper - key: ${{ hashFiles('**/build.gradle', '**/gradle-wrapper.properties') }} + key: ${{ hashFiles('**/build.gradle', '**/gradle-wrapper.properties', '**/gradle.properties') }} - name: Build run: | chmod +x ./gradlew @@ -25,4 +25,4 @@ jobs: uses: actions/upload-artifact@v4 with: name: Mod Jar - path: build/libs/**.jar \ No newline at end of file + path: build/libs/**.jar diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..ebfbcba5 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,32 @@ +on: + push: + tags: ["*"] +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Clone Repository + uses: actions/checkout@v4 + - name: Setup Java + uses: actions/setup-java@v4 + with: + java-version: '21' + distribution: 'temurin' + - name: Cache + uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ hashFiles('**/build.gradle', '**/gradle-wrapper.properties', '**/gradle.properties') }} + - name: Grab Changelog from Commit Message Body + run: | + changelog=$(echo -e "$MESSAGE" | sed -n '/^$/,$p' | sed '1d') + echo $changelog + echo "CHANGELOG=$changelog" >> $GITHUB_ENV + env: + MESSAGE: ${{ github.event.head_commit.message }} + - name: Release + run: | + chmod +x ./gradlew + ./gradlew publishMods --no-daemon diff --git a/build.gradle b/build.gradle index 2f0db831..b2485a48 100644 --- a/build.gradle +++ b/build.gradle @@ -4,6 +4,7 @@ plugins { id 'idea' id 'maven-publish' id 'net.neoforged.gradle.userdev' version '7.0.163' + id 'me.modmuss50.mod-publish-plugin' version "0.7.4" } tasks.named('wrapper', Wrapper).configure { @@ -166,3 +167,30 @@ idea { downloadJavadoc = true } } + +publishMods { + def cfToken = providers.environmentVariable("CF_TOKEN") + def mrToken = providers.environmentVariable("MR_TOKEN") + dryRun = !cfToken.isPresent() || !mrToken.isPresent() + changelog = providers.environmentVariable("COMMIT_MESSAGE").orElse("") + version = mod_version + type = me.modmuss50.mpp.ReleaseType.valueOf(mod_release_state) + file = jar.archiveFile + modLoaders.add("neoforge") + + modrinth { + accessToken = mrToken + projectId = "4cJkN3aF" + minecraftVersions.add(minecraft_version) + requires("patchouli") + optional("curios-continuation") + } + + curseforge { + accessToken = cfToken + projectId = "306626" + minecraftVersions.add(minecraft_version) + requires("patchouli") + optional("curios-continuation") + } +} diff --git a/gradle.properties b/gradle.properties index 6ff05b29..2bdb5a71 100644 --- a/gradle.properties +++ b/gradle.properties @@ -32,6 +32,7 @@ mod_name=NaturesAura mod_license=MIT # The mod version. See https://semver.org/ mod_version=41.3 +mod_release_state=BETA # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # This should match the base package used for the mod sources. # See https://maven.apache.org/guides/mini/guide-naming-conventions.html