Skip to content

Commit

Permalink
Release workflow?
Browse files Browse the repository at this point in the history
  • Loading branch information
ang-xd committed Dec 11, 2022
1 parent c26e9bb commit 2621688
Show file tree
Hide file tree
Showing 9 changed files with 256 additions and 20 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -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}}"
44 changes: 44 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
with:
path: "./forge/build/libs"
name: Forge Jars
- name: Upload a Build Artifact
uses: actions/[email protected]
with:
path: "./fabric/build/libs"
name: Fabric Jars
- name: Upload a Build Artifact
uses: actions/[email protected]
with:
path: "./common/build/libs"
name: Common Jars
37 changes: 37 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions .run/Build All.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Build All" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="build" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<method v="2" />
</configuration>
</component>
35 changes: 34 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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()
}
Expand All @@ -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()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
41 changes: 32 additions & 9 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
}
36 changes: 27 additions & 9 deletions forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
}
5 changes: 4 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit 2621688

Please sign in to comment.