From 26216884a5ee5e02f4c479326079a624565753d3 Mon Sep 17 00:00:00 2001 From: ang-xd Date: Sun, 11 Dec 2022 10:05:50 -0500 Subject: [PATCH] Release workflow? --- .github/workflows/codeql-analysis.yml | 51 +++++++++++++++++++ .github/workflows/gradle.yml | 44 ++++++++++++++++ .github/workflows/release.yml | 37 ++++++++++++++ .run/Build All.run.xml | 23 +++++++++ build.gradle | 35 ++++++++++++- .../paragon/api/interfaces/Description.java | 4 ++ fabric/build.gradle | 41 +++++++++++---- forge/build.gradle | 36 +++++++++---- gradle.properties | 5 +- 9 files changed, 256 insertions(+), 20 deletions(-) create mode 100644 .github/workflows/codeql-analysis.yml create mode 100644 .github/workflows/gradle.yml create mode 100644 .github/workflows/release.yml create mode 100644 .run/Build All.run.xml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000..45bbe10 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,51 @@ +name: "CodeQL" + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + schedule: + - cron: '29 19 * * 4' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'java' ] + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + # ℹī¸ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{matrix.language}}" \ No newline at end of file diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml new file mode 100644 index 0000000..15faa05 --- /dev/null +++ b/.github/workflows/gradle.yml @@ -0,0 +1,44 @@ +name: Java Gradle + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +permissions: + contents: read + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'adopt' + - uses: burrunan/gradle-cache-action@v1 + name: Build + with: + job-id: jdk18 + arguments: clean build --no-build-cache + gradle-version: wrapper + - name: Upload a Build Artifact + uses: actions/upload-artifact@v3.1.0 + with: + path: "./forge/build/libs" + name: Forge Jars + - name: Upload a Build Artifact + uses: actions/upload-artifact@v3.1.0 + with: + path: "./fabric/build/libs" + name: Fabric Jars + - name: Upload a Build Artifact + uses: actions/upload-artifact@v3.1.0 + with: + path: "./common/build/libs" + name: Common Jars \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..a8697c7 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,37 @@ +name: Release Workflow + +on: + release: + types: [published] + + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'adopt' + - name: Validate Gradle Wrapper + uses: gradle/wrapper-validation-action@v1 + - run: chmod +x gradlew + - uses: burrunan/gradle-cache-action@v1 + name: Build + with: + job-id: jdk18 + arguments: clean build --no-build-cache + gradle-version: wrapper + - name: Release to CurseForge and Modrinth + uses: gradle/gradle-build-action@v2 + env: + CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }} + MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} + with: + arguments: publishUnified --stacktrace --no-daemon diff --git a/.run/Build All.run.xml b/.run/Build All.run.xml new file mode 100644 index 0000000..da458d1 --- /dev/null +++ b/.run/Build All.run.xml @@ -0,0 +1,23 @@ + + + + + + + true + true + false + + + \ No newline at end of file diff --git a/build.gradle b/build.gradle index 3f0ca21..9120df7 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,9 @@ +import java.text.SimpleDateFormat + plugins { id "architectury-plugin" version "3.4-SNAPSHOT" id "dev.architectury.loom" version "0.12.0-SNAPSHOT" apply false + id "me.shedaniel.unified-publishing" version "0.1.+" apply false } architectury { @@ -27,12 +30,12 @@ allprojects { apply plugin: "java" apply plugin: "architectury-plugin" apply plugin: "maven-publish" + apply plugin: "me.shedaniel.unified-publishing" archivesBaseName = rootProject.archives_base_name version = rootProject.mod_version group = rootProject.maven_group - repositories { mavenCentral() } @@ -42,6 +45,36 @@ allprojects { options.release = 17 } + ext { + releaseChangelog = { + def dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm") + dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")) + def branch + if(System.env.BRANCH_NAME) { + branch = System.env.BRANCH_NAME + branch = branch.substring(branch.lastIndexOf("/") + 1) + } else { + branch = "git rev-parse --abbrev-ref HEAD".execute().in.text.trim() + } + if(branch == "HEAD") { + branch = "git rev-parse --short HEAD".execute().in.text.trim() + } + def time = dateFormat.format(new Date()) + def changes = new StringBuilder() + changes << "## Deeper and Darker v${rootProject.mod_version} for ${rootProject.minecraft_version}\nUpdated at **$time**." + def proc = "git log --max-count=200 --pretty=format:%s".execute() + proc.in.eachLine { line -> + def processedLine = line.toString() + if(!processedLine.contains("New translations") && !processedLine.contains("Merge") && !processedLine.contains("branch")) { + changes << "\n- ${processedLine.capitalize()}" + } + } + proc.waitFor() + return changes.toString() + } + } + + java { withSourcesJar() } diff --git a/common/src/main/java/com/kyanite/paragon/api/interfaces/Description.java b/common/src/main/java/com/kyanite/paragon/api/interfaces/Description.java index 36e3a1d..bb13c38 100644 --- a/common/src/main/java/com/kyanite/paragon/api/interfaces/Description.java +++ b/common/src/main/java/com/kyanite/paragon/api/interfaces/Description.java @@ -1,5 +1,9 @@ package com.kyanite.paragon.api.interfaces; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +@Retention(RetentionPolicy.RUNTIME) public @interface Description { String value(); } diff --git a/fabric/build.gradle b/fabric/build.gradle index 3a771d7..1aa8a50 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -72,16 +72,39 @@ task renameJarForPublication(type: Zip, dependsOn: remapJar) { assemble.dependsOn renameJarForPublication -publishing { - publications { - mavenFabric(MavenPublication) { - artifactId = rootProject.archives_base_name + "-" + project.name - from components.java +unifiedPublishing { + project { + displayName = "[Fabric $rootProject.minecraft_version] $project.version" + releaseType = "release" + changelog = releaseChangelog() + gameVersions = ["${rootProject.minecraft_version}"] + // Quilt can load fabric mods, so meh. + gameLoaders = ["fabric", "quilt"] + mainPublication renameJarForPublication + + relations { + depends { + curseforge = "fabric-api" + modrinth = "fabric-api" + } + } + + var CURSE_API_KEY = project.findProperty("CURSEFORGE_TOKEN") ?: System.getenv("CURSEFORGE_TOKEN") + if(CURSE_API_KEY != null) { + curseforge { + token = CURSE_API_KEY + id = rootProject.curseforge_id + gameVersions.addAll "Java 17", "1.19", "1.19.1", "1.19.2" + } } - } - // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. - repositories { - // Add repositories to publish to here. + var MODRINTH_TOKEN = project.findProperty("MODRINTH_TOKEN") ?: System.getenv("MODRINTH_TOKEN") + if(MODRINTH_TOKEN != null) { + modrinth { + token = MODRINTH_TOKEN + id = rootProject.modrinth_id + version = "$project.version+$project.name" + } + } } } \ No newline at end of file diff --git a/forge/build.gradle b/forge/build.gradle index 589a238..e0c6738 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -72,16 +72,34 @@ task renameJarForPublication(type: Zip, dependsOn: remapJar) { assemble.dependsOn renameJarForPublication -publishing { - publications { - mavenForge(MavenPublication) { - artifactId = rootProject.archives_base_name + "-" + project.name - from components.java +unifiedPublishing { + project { + displayName = "[Forge $rootProject.minecraft_version] $project.version" + releaseType = "release" + changelog = releaseChangelog() + gameVersions = ["${rootProject.minecraft_version}"] + gameLoaders = ["forge"] + mainPublication renameJarForPublication + + relations { + } + + var CURSE_API_KEY = project.findProperty("CURSEFORGE_TOKEN") ?: System.getenv("CURSEFORGE_TOKEN") + if(CURSE_API_KEY != null) { + curseforge { + token = CURSE_API_KEY + id = rootProject.curseforge_id + gameVersions.addAll "Java 17", "1.19", "1.19.1", "1.19.2" + } } - } - // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. - repositories { - // Add repositories to publish to here. + var MODRINTH_TOKEN = project.findProperty("MODRINTH_TOKEN") ?: System.getenv("MODRINTH_TOKEN") + if(MODRINTH_TOKEN != null) { + modrinth { + token = MODRINTH_TOKEN + id = rootProject.modrinth_id + version = "$project.version+$project.name" + } + } } } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 2eb98ba..554d4a4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ minecraft_version=1.19 supported_version=1.19-1.19.3 archives_base_name=paragon -mod_version=3.0.0 +mod_version=3.0.2 maven_group=com.kyanite architectury_version=5.12.45 @@ -13,3 +13,6 @@ fabric_loader_version=0.14.11 fabric_api_version=0.58.0+1.19 forge_version=1.19-41.1.0 + +modrinth_id=M1720s8h +curseforge_id=689888 \ No newline at end of file