feat(build): add release automation tasks and CI/CD workflows
Some checks failed
CI / test (push) Has been cancelled
Some checks failed
CI / test (push) Has been cancelled
- Introduced Gradle tasks for release preparation, version bumping, and git tagging. - Added CI workflow for continuous integration on pushes and pull requests. - Implemented release workflow for automated builds and Gitea releases upon tag pushes. - Created scripts for manual release processes on Windows and Linux/macOS. - Documented the release process and Gitea Actions setup in the new RELEASE.md and setup-gitea-actions.md files.
This commit is contained in:
81
build.gradle
81
build.gradle
@@ -3,6 +3,7 @@ plugins {
|
||||
id 'idea'
|
||||
id 'maven-publish'
|
||||
id 'net.minecraftforge.gradle' version '[6.0,6.2)'
|
||||
id 'org.ajoberstar.grgit' version '5.2.0'
|
||||
}
|
||||
|
||||
version = mod_version
|
||||
@@ -197,3 +198,83 @@ publishing {
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
|
||||
}
|
||||
|
||||
// Release automation tasks
|
||||
task prepareRelease {
|
||||
dependsOn 'build'
|
||||
group = 'release'
|
||||
description = 'Prepares release files and creates git tag'
|
||||
|
||||
doLast {
|
||||
def tagName = "v${mod_version}"
|
||||
def jarFile = file("${buildDir}/libs/${mod_id}-${mod_version}.jar")
|
||||
|
||||
if (!jarFile.exists()) {
|
||||
throw new GradleException("JAR file not found: ${jarFile}")
|
||||
}
|
||||
|
||||
println "Release prepared:"
|
||||
println " Tag: ${tagName}"
|
||||
println " JAR: ${jarFile}"
|
||||
println ""
|
||||
println "Next steps:"
|
||||
println "1. Push the tag: git push origin ${tagName}"
|
||||
println "2. Create release on Gitea manually or use Gitea Actions"
|
||||
}
|
||||
}
|
||||
|
||||
// Task to create a git tag
|
||||
task createTag {
|
||||
doLast {
|
||||
def tagName = "v${mod_version}"
|
||||
try {
|
||||
grgit.tag.add(name: tagName, message: "Release ${tagName}")
|
||||
println "Created tag: ${tagName}"
|
||||
} catch (Exception e) {
|
||||
println "Tag ${tagName} might already exist: ${e.message}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Task to push tags
|
||||
task pushTags {
|
||||
doLast {
|
||||
try {
|
||||
grgit.push(tags: true)
|
||||
println "Pushed tags to remote"
|
||||
} catch (Exception e) {
|
||||
println "Error pushing tags: ${e.message}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Combined release task
|
||||
task release {
|
||||
dependsOn 'createTag', 'pushTags', 'prepareRelease'
|
||||
group = 'release'
|
||||
description = 'Creates a git tag, pushes it, and prepares for Gitea release'
|
||||
}
|
||||
|
||||
// Task to bump version
|
||||
task bumpVersion {
|
||||
doLast {
|
||||
def currentVersion = mod_version
|
||||
def versionParts = currentVersion.split('\\.')
|
||||
def major = versionParts[0] as Integer
|
||||
def minor = versionParts[1] as Integer
|
||||
def patch = versionParts[2] as Integer
|
||||
|
||||
// Increment patch version
|
||||
patch++
|
||||
def newVersion = "${major}.${minor}.${patch}"
|
||||
|
||||
// Update gradle.properties
|
||||
def propsFile = file('gradle.properties')
|
||||
def propsContent = propsFile.text
|
||||
propsContent = propsContent.replaceAll("mod_version=${mod_version}", "mod_version=${newVersion}")
|
||||
propsFile.text = propsContent
|
||||
|
||||
println "Version bumped from ${currentVersion} to ${newVersion}"
|
||||
println "Don't forget to commit and push the version change!"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user