From 3cf074901a1ca04c906d780af6b279f3d1e36436 Mon Sep 17 00:00:00 2001 From: Hugman Date: Sun, 31 Jan 2021 12:25:14 +0100 Subject: [PATCH] Added auto-release system --- .../workflows/{build.yml => check_build.yml} | 12 ++- .github/workflows/release_major.yml | 60 ++++++++++++++ .github/workflows/release_minor.yml | 60 ++++++++++++++ .github/workflows/release_patch.yml | 60 ++++++++++++++ build.gradle | 80 +------------------ gradle.properties | 45 +++++++++-- src/main/resources/fabric.mod.json | 16 ++-- 7 files changed, 235 insertions(+), 98 deletions(-) rename .github/workflows/{build.yml => check_build.yml} (81%) create mode 100644 .github/workflows/release_major.yml create mode 100644 .github/workflows/release_minor.yml create mode 100644 .github/workflows/release_patch.yml diff --git a/.github/workflows/build.yml b/.github/workflows/check_build.yml similarity index 81% rename from .github/workflows/build.yml rename to .github/workflows/check_build.yml index f78c34f7..3c97e440 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/check_build.yml @@ -3,21 +3,19 @@ # certain platforms or Java versions, and provides a first line of defence # against bad commits. -name: Build +name: Check Build on: [pull_request, push] jobs: build: strategy: matrix: - # Use these Java versions java: [ - 1.8, # Minimum supported by Minecraft - 11, # Current Java LTS - 15 # Latest version + 1.8, # Minimum + 11, # LTS + 15 # Latest ] - # and run on both Linux and Windows - os: [ubuntu-20.04, windows-latest] + os: [ ubuntu-20.04 ] runs-on: ${{ matrix.os }} steps: - name: Checkout repository diff --git a/.github/workflows/release_major.yml b/.github/workflows/release_major.yml new file mode 100644 index 00000000..17a1dc5b --- /dev/null +++ b/.github/workflows/release_major.yml @@ -0,0 +1,60 @@ +name: Release Major +on: [ workflow_dispatch ] # Manual trigger +jobs: + build: + strategy: + matrix: + java: [ 11 ] + os: [ ubuntu-20.04 ] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Get previous tag + id: previous-tag + uses: WyriHaximus/github-action-get-previous-tag@1.0.0 + - name: Get SemVer increments + id: semver + uses: WyriHaximus/github-action-next-semvers@v1.0 + with: + version: ${{ steps.previous-tag.outputs.tag }} + - name: Create version tag + uses: actions/github-script@v3 + with: + github-token: ${{ github.token }} + script: | + github.git.createRef({ + owner: context.repo.owner, + repo: context.repo.repo, + ref: "refs/tags/v${{ steps.semver.outputs.major }}", + sha: context.sha + }) + - name: Fetch tags + run: git fetch --tags + - name: Get current tag + id: current-tag + uses: WyriHaximus/github-action-get-previous-tag@1.0.0 + - name: Validate Gradle wrapper + uses: gradle/wrapper-validation-action@v1 + - name: Setup JDK ${{ matrix.java }} + uses: actions/setup-java@v1 + with: + java-version: ${{ matrix.java }} + - name: Make Gradle wrapper executable + if: ${{ runner.os != 'Windows' }} + run: chmod +x ./gradlew + - name: Build and release + run: ./gradlew generateChangelog build curseforge github modrinth --stacktrace -PlastTag="${{ steps.previous-tag.outputs.tag }}" -PcurrentTag="${{ steps.current-tag.outputs.tag }}" + env: + CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }} + MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GH_API_KEY }} + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} + - name: Capture build artifacts + if: ${{ runner.os == 'Linux' && matrix.java == '11' }} + uses: actions/upload-artifact@v2 + with: + name: Artifacts + path: build/libs/ \ No newline at end of file diff --git a/.github/workflows/release_minor.yml b/.github/workflows/release_minor.yml new file mode 100644 index 00000000..2a64b8d9 --- /dev/null +++ b/.github/workflows/release_minor.yml @@ -0,0 +1,60 @@ +name: Release Minor +on: [ workflow_dispatch ] # Manual trigger +jobs: + build: + strategy: + matrix: + java: [ 11 ] + os: [ ubuntu-20.04 ] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Get previous tag + id: previous-tag + uses: WyriHaximus/github-action-get-previous-tag@1.0.0 + - name: Get SemVer increments + id: semver + uses: WyriHaximus/github-action-next-semvers@v1.0 + with: + version: ${{ steps.previous-tag.outputs.tag }} + - name: Create version tag + uses: actions/github-script@v3 + with: + github-token: ${{ github.token }} + script: | + github.git.createRef({ + owner: context.repo.owner, + repo: context.repo.repo, + ref: "refs/tags/v${{ steps.semver.outputs.minor }}", + sha: context.sha + }) + - name: Fetch tags + run: git fetch --tags + - name: Get current tag + id: current-tag + uses: WyriHaximus/github-action-get-previous-tag@1.0.0 + - name: Validate Gradle wrapper + uses: gradle/wrapper-validation-action@v1 + - name: Setup JDK ${{ matrix.java }} + uses: actions/setup-java@v1 + with: + java-version: ${{ matrix.java }} + - name: Make Gradle wrapper executable + if: ${{ runner.os != 'Windows' }} + run: chmod +x ./gradlew + - name: Build and release + run: ./gradlew generateChangelog build curseforge github modrinth --stacktrace -PlastTag="${{ steps.previous-tag.outputs.tag }}" -PcurrentTag="${{ steps.current-tag.outputs.tag }}" + env: + CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }} + MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GH_API_KEY }} + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} + - name: Capture build artifacts + if: ${{ runner.os == 'Linux' && matrix.java == '11' }} + uses: actions/upload-artifact@v2 + with: + name: Artifacts + path: build/libs/ \ No newline at end of file diff --git a/.github/workflows/release_patch.yml b/.github/workflows/release_patch.yml new file mode 100644 index 00000000..653270be --- /dev/null +++ b/.github/workflows/release_patch.yml @@ -0,0 +1,60 @@ +name: Release Patch +on: [ workflow_dispatch ] # Manual trigger +jobs: + build: + strategy: + matrix: + java: [ 11 ] + os: [ ubuntu-20.04 ] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Get previous tag + id: previous-tag + uses: WyriHaximus/github-action-get-previous-tag@1.0.0 + - name: Get SemVer increments + id: semver + uses: WyriHaximus/github-action-next-semvers@v1.0 + with: + version: ${{ steps.previous-tag.outputs.tag }} + - name: Create version tag + uses: actions/github-script@v3 + with: + github-token: ${{ github.token }} + script: | + github.git.createRef({ + owner: context.repo.owner, + repo: context.repo.repo, + ref: "refs/tags/v${{ steps.semver.outputs.patch }}", + sha: context.sha + }) + - name: Fetch tags + run: git fetch --tags + - name: Get current tag + id: current-tag + uses: WyriHaximus/github-action-get-previous-tag@1.0.0 + - name: Validate Gradle wrapper + uses: gradle/wrapper-validation-action@v1 + - name: Setup JDK ${{ matrix.java }} + uses: actions/setup-java@v1 + with: + java-version: ${{ matrix.java }} + - name: Make Gradle wrapper executable + if: ${{ runner.os != 'Windows' }} + run: chmod +x ./gradlew + - name: Build and release + run: ./gradlew generateChangelog build curseforge github modrinth --stacktrace -PlastTag="${{ steps.previous-tag.outputs.tag }}" -PcurrentTag="${{ steps.current-tag.outputs.tag }}" + env: + CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }} + MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GH_API_KEY }} + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} + - name: Capture build artifacts + if: ${{ runner.os == 'Linux' && matrix.java == '11' }} + uses: actions/upload-artifact@v2 + with: + name: Artifacts + path: build/libs/ \ No newline at end of file diff --git a/build.gradle b/build.gradle index 250f7d5f..05756df6 100644 --- a/build.gradle +++ b/build.gradle @@ -1,36 +1,10 @@ -buildscript { - dependencies { - classpath 'de.guntram.mcmod:crowdin-translate:1.3-pre1-hugman' - } - repositories { - maven { - name = 'CrowdinTranslate source' - url = "https://minecraft.guntram.de/maven/" - } - } -} - -plugins { - id 'fabric-loom' version '0.5-SNAPSHOT' - id 'maven-publish' -} - -sourceCompatibility = JavaVersion.VERSION_1_8 -targetCompatibility = JavaVersion.VERSION_1_8 - -archivesBaseName = project.mod_id -version = project.mod_version -group = "com.github.DawnTeam" - -apply plugin: 'de.guntram.mcmod.crowdin-translate' -crowdintranslate.setCrowdinProjectname 'dawnteam' -crowdintranslate.setMinecraftProjectName project.mod_id -crowdintranslate.setJsonSourceName project.mod_id +apply from: 'https://raw.githubusercontent.com/DawnTeamMC/DawnTeamMC/master/build_template.gradle' repositories { jcenter() mavenLocal() maven { url 'https://jitpack.io' } + maven { url 'http://maven.terraformersmc.com/' } } dependencies { @@ -39,55 +13,7 @@ dependencies { modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" - modApi "com.github.DawnTeamMC:DawnAPI:${project.dawn_version}" + modApi "com.github.DawnTeamMC:DawnAPI:v${project.dawn_version}" compileOnly "com.google.code.findbugs:jsr305:3.0.2" -} - -processResources { - inputs.property "version", project.version - - filesMatching("fabric.mod.json") { - expand "version": project.version - } -} - -tasks.withType(JavaCompile).configureEach { - it.options.encoding = "UTF-8" - - def targetVersion = 8 - if (JavaVersion.current().isJava9Compatible()) { - it.options.release = targetVersion - } -} - -java { - withSourcesJar() -} - -jar { - from("LICENSE") { - rename { "${it}_${project.archivesBaseName}" } - } -} - -build { - dependsOn downloadTranslations -} - -publishing { - publications { - mavenJava(MavenPublication) { - artifact(sourcesJar) { - builtBy remapSourcesJar - } - - afterEvaluate { - artifact remapJar - } - } - } - - repositories { - } } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index f50cb9f4..50ae56be 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,10 +1,43 @@ org.gradle.jvmargs=-Xmx1G -mod_version=1.3.1 + +# Mod Metadata mod_id=wild_explorer +mod_name=Wild Explorer +mod_logo=https://raw.githubusercontent.com/DawnTeamMC/DawnTeamMC/master/wild_explorer/logo.png +mod_color=0x37c10c +mod_default_release_type=stable + +# Loader Metadata +loader_name=Fabric +loader_icon=https://fabricmc.net/assets/logo.png + +# GitHub Metadata +github_name=WildExplorer + +# CurseForge Metadata +curseforge_slug=wild-explorer +curseforge_id=399648 +curseforge_game_versions=1.16.2, 1.16.3, 1.16.4, 1.16.5, Fabric +curseforge_embedded_libraries= +curseforge_required_dependencies=fabric-api, dawn +curseforge_optional_dependencies= + +# Modrinth Metadata +modrinth_slug=wild_explorer +modrinth_id=GuE5FpvB +modrinth_game_versions=1.16.2, 1.16.3, 1.16.4, 1.16.5 +modrinth_mod_loaders=fabric + # check these on https://modmuss50.me/fabric.html -minecraft_version=1.16.4 -yarn_mappings=1.16.4+build.7 -loader_version=0.10.8 -fabric_version=0.28.4+1.16 +minecraft_version=1.16.5 +yarn_mappings=1.16.5+build.3 +loader_version=0.11.1 +fabric_version=0.30.0+1.16 # https://github.com/DawnTeamMC/DawnAPI -dawn_version=1.6.1 \ No newline at end of file +dawn_version=1.6.2 + +# Changelog Options +use_project_username=false +changelog_hide_unimportant_commits=true +changelog_max_commit_search=200 +discord_webhook_changelog_line_limit=10 \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 8185e7a1..4a9ab7e2 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -1,17 +1,18 @@ { - "name": "Wild Explorer", - "id": "wild_explorer", + "schemaVersion": 1, + "name": "${mod_name}", + "id": "${mod_id}", "version": "${version}", - "icon": "assets/wild_explorer/textures/logo.png", + "icon": "assets/${mod_id}/textures/logo.png", "description": "Fancy and simplistic animals, biomes, structures and more!", "authors": [ "Hugman", "Dawn Team" ], "contact": { - "homepage": "https://www.curseforge.com/minecraft/mc-mods/wild-explorer", - "sources": "https://github.com/DawnTeamMC/WildExplorer", - "issues": "https://github.com/DawnTeamMC/WildExplorer/issues" + "homepage": "https://www.curseforge.com/minecraft/mc-mods/${curseforge_slug}", + "sources": "https://github.com/DawnTeamMC/${github_name}", + "issues": "https://github.com/DawnTeamMC/${github_name}/issues" }, "environment": "*", "entrypoints": { @@ -39,6 +40,5 @@ "projectID": 399648 } }, - "license": "MIT", - "schemaVersion": 1 + "license": "MIT" }