Skip to content

Commit

Permalink
Add auto curse pushing
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredlll08 committed Mar 8, 2023
1 parent 95b8989 commit bfa391e
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -21,3 +21,4 @@
/run/
usernamecache.json
*.stackdump
changelog.md
50 changes: 50 additions & 0 deletions Jenkinsfile
@@ -0,0 +1,50 @@
#!/usr/bin/env groovy

pipeline {
agent any
tools {
jdk "jdk8u292-b10"
}
stages {
stage('Clean') {
steps {
withCredentials([file(credentialsId: 'mod_build_secrets', variable: 'ORG_GRADLE_PROJECT_secretFile')]) {
echo 'Cleaning Project'
sh 'chmod +x gradlew'
sh './gradlew clean'
}
}
}
stage('Setup') {
steps {
withCredentials([file(credentialsId: 'mod_build_secrets', variable: 'ORG_GRADLE_PROJECT_secretFile')]) {
echo 'Setting up Workspace'
sh './gradlew setupDecompWorkspace'
}
}
}
stage('Build') {
steps {
withCredentials([file(credentialsId: 'mod_build_secrets', variable: 'ORG_GRADLE_PROJECT_secretFile')]) {
echo 'Building'
sh './gradlew build'
}
}
}
stage('Git Changelog') {
steps {
withCredentials([file(credentialsId: 'mod_build_secrets', variable: 'ORG_GRADLE_PROJECT_secretFile')]) {
sh './gradlew genGitChangelog'
}
}
}
stage('Publish') {
steps {
withCredentials([file(credentialsId: 'mod_build_secrets', variable: 'ORG_GRADLE_PROJECT_secretFile')]) {
echo 'Deploying to CurseForge'
sh './gradlew curseforge'
}
}
}
}
}
54 changes: 51 additions & 3 deletions build.gradle
Expand Up @@ -7,13 +7,25 @@ buildscript {
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3.4'
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
}
}
plugins {
id "com.matthewprenger.cursegradle" version "1.4.0"
}
apply plugin: 'net.minecraftforge.gradle.forge'

version = "3.0.11"
group= "us.getfluxed.controlling" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
apply from: 'https://raw.githubusercontent.com/MinecraftModDevelopment/Gradle-Collection/22e7d543a18cd30675277fbfa3669e3d9e206010/generic/secrets.gradle'

if (project.hasProperty('secretFile')) {
loadSecrets(new File((String) findProperty('secretFile')))
}

version = "3.0.12"
if (System.getenv('BUILD_NUMBER') != null) {
version += "." + System.getenv('BUILD_NUMBER')
}
group= "com.blamejared.controlling"
archivesBaseName = "Controlling"

sourceCompatibility = targetCompatibility = "1.8"
Expand Down Expand Up @@ -49,3 +61,39 @@ processResources
exclude 'mcmod.info'
}
}

task genGitChangelog() {
def stdout = new ByteArrayOutputStream()
// first commit to check from, in our case the first commit of the branch
String firstCommit = '95b89895de2f266d3d642760ce64c98b3d8576d2';
String repoLink = "https://github.com/jaredlll08/Controlling/commit/"
// was having issues with grep and spaces in the regex
exec {
commandLine 'git', 'log', '-i', '--grep=version\\spush', '--grep=open\\sbeta\\sspecific\\scode', '--pretty=tformat:%H', '--date=local', firstCommit + '..@{0}'
standardOutput = stdout
}
if (stdout.toString().trim().indexOf("\n") >= 0) {
firstCommit = stdout.toString().split("\n")[0].trim();
}
System.out.println("Last version hash: \"" + firstCommit + "\"");
stdout = new ByteArrayOutputStream()
def test = exec {
commandLine 'git', 'log', '--pretty=tformat:- [%s](' + repoLink + '%H) - %aN - %cd', '--max-parents=1', '--date=local', firstCommit + "..@"
standardOutput = stdout
}
File file = new File("changelog.md")
file.write("### Current version: " + project.version)
file.append("\n" + stdout.toString())
System.out.println("Changelog generated!")
}

curseforge {
apiKey = findProperty('curseforge_api_token') ?: 0
project {
id = "250398"
releaseType = 'release'
changelog = file("changelog.md")
changelogType = 'markdown'
addGameVersion '1.12.2'
}
}

0 comments on commit bfa391e

Please sign in to comment.