diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fada0ab..50495da 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,28 +1,25 @@ name: build -on: - pull_request: - push: - branches: - - '**' +on: [pull_request, push] jobs: build: runs-on: ubuntu-latest steps: - name: checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: validate gradle wrapper - uses: gradle/wrapper-validation-action@v1 + uses: gradle/wrapper-validation-action@v2 - name: setup jdk 21 - uses: actions/setup-java@v1 + uses: actions/setup-java@v4 with: java-version: 21 + distribution: 'microsoft' - name: make gradle wrapper executable run: chmod +x ./gradlew - name: build run: ./gradlew build - name: capture build artifacts - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: - name: Vanish + name: Artifacts path: build/libs/ \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f024b5e..e447260 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,40 +1,21 @@ name: release - -on: - workflow_dispatch: - push: - tags: - - 'v*.*.*\+1.**' +on: [workflow_dispatch] jobs: - upload: + release: runs-on: ubuntu-latest steps: - - name: Checkout repository - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up JDK 21 - uses: actions/setup-java@v2 - with: - java-version: '21' - distribution: 'temurin' - - name: Grant execute permission to gradlew - run: chmod +x gradlew - - name: Build with Gradle - run: ./gradlew build - - name: Set up Environment Variables - run: | - echo "MINECRAFT_VERSION="$(grep 'minecraft_version' gradle.properties | cut -f2- -d=)"" >> $GITHUB_ENV - echo "MOD_VERSION="$(grep 'mod_version' gradle.properties | cut -f2- -d=)"" >> $GITHUB_ENV - - name: Install changelog parser - uses: taiki-e/install-action@parse-changelog - - name: Parse changelog - run: parse-changelog CHANGELOG.md ${{ env.MOD_VERSION }} > changes.md - - uses: Kir-Antipov/mc-publish@v3.3 + uses: actions/setup-java@v4 with: - modrinth-token: ${{ secrets.MODRINTH_TOKEN }} - modrinth-dependencies: | - curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }} - github-token: ${{ secrets.GITHUB_TOKEN }} - changelog-file: changes.md - name: Vanish ${{ env.MOD_VERSION }} for ${{ env.MINECRAFT_VERSION }} - files: build/libs/!(*-@(dev|sources|shadow)).jar \ No newline at end of file + distribution: 'adopt' + java-version: 21 + - name: Make gradlew executable + run: chmod +x ./gradlew + - name: Publish mods + run: ./gradlew build publishMods + env: + CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }} + MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/build.gradle b/build.gradle index c9a87e6..c31a675 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,11 @@ +import org.jetbrains.changelog.Changelog + plugins { id 'fabric-loom' version '1.6-SNAPSHOT' id 'io.github.goooler.shadow' version '8.1.7' id 'maven-publish' + id "me.modmuss50.mod-publish-plugin" version "0.5.1" + id 'org.jetbrains.changelog' version '2.+' } sourceCompatibility = JavaVersion.VERSION_21 @@ -51,6 +55,33 @@ remapJar { from zipTree(shadowJar.archiveFile) dependsOn shadowJar } +publishMods { + file = remapJar.archiveFile + type = STABLE + changelog = fetchChangelog() + + displayName = "Vanish ${version.get()}" + modLoaders.add("fabric") + modLoaders.add("quilt") + + + curseforge { + accessToken = providers.environmentVariable("CURSEFORGE_API_KEY") + projectId = "676275" + minecraftVersions.add(project.curseforge_minecraft_version) + } + modrinth { + accessToken = providers.environmentVariable("MODRINTH_TOKEN") + projectId = "UL4bJFDY" + minecraftVersions.add(project.minecraft_version) + } + github { + accessToken = providers.environmentVariable("GITHUB_TOKEN") + repository = providers.environmentVariable("GITHUB_REPOSITORY").getOrElse("DrexHD/dryrun") + commitish = providers.environmentVariable("GITHUB_REF_NAME").getOrElse("dryrun") + } +} + processResources { inputs.property "version", project.version @@ -86,10 +117,22 @@ publishing { } } +private String fetchChangelog() { + def log = getChangelog.changelog.get() + if (log.has(project.mod_version)) { + return log.renderItem( + log.get(project.mod_version).withHeader(false), + Changelog.OutputType.MARKDOWN + ) + } else { + return "" + } +} + //Mixin hotswap afterEvaluate { loom.runs.configureEach { // https://fabricmc.net/wiki/tutorial:mixin_hotswaps vmArg "-javaagent:${ configurations.compileClasspath.find { it.name.contains("sponge-mixin") } }" } -} \ No newline at end of file +} diff --git a/gradle.properties b/gradle.properties index 1aaa319..0b74e1f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,6 +3,7 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/develop minecraft_version=1.21 +curseforge_minecraft_version=1.21 loader_version=0.15.11 # Mod Properties mod_version=1.5.5 diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 00f39fa..cb38345 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -18,15 +18,6 @@ "com.llamalad7.mixinextras.MixinExtrasBootstrap::init" ] }, - "custom": { - "modmanager": { - "curseforge": 676275, - "modrinth": "UL4bJFDY" - }, - "mc-publish": { - "quilt": true - } - }, "mixins": [ "vanish.mixins.json" ],