mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-26 23:03:01 +00:00
Overhaul build/release to use tags
This commit is contained in:
1 parent
21d515c6b5
commit
241ffb71d7
6 files changed
+161
-115
No files matched your search
@@ -0,0 +1,10 @@
|
||||
/build
|
||||
/bin
|
||||
/out
|
||||
/run
|
||||
.gradle
|
||||
.dockerignore
|
||||
Dockerfile
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
FROM openjdk:8-jdk-slim
|
||||
|
||||
RUN apt-get update && apt-get install -y python3-requests make git
|
||||
|
||||
# Caching step; ForgeGradle requires a fairly significant number
|
||||
# of downloads that don't vary unless build.gradle changes. We
|
||||
# improve overall build time form 4m+ to 30s by doing this as part
|
||||
# of standard image build
|
||||
COPY gradle/ /tmp/gradle/
|
||||
COPY build.gradle build.properties gradle* /tmp/
|
||||
RUN (cd /tmp && ./gradlew setupCiWorkspace build)
|
||||
|
||||
RUN mkdir /mekanism
|
||||
COPY . /mekanism
|
||||
Vendored
-34
@@ -1,34 +0,0 @@
|
||||
pipeline {
|
||||
agent any
|
||||
|
||||
/*tools {
|
||||
gradle "Gradle 4.4"
|
||||
}*/
|
||||
|
||||
stages {
|
||||
stage('Build') {
|
||||
steps {
|
||||
sh "./gradlew"
|
||||
}
|
||||
}
|
||||
stage('Deploy') {
|
||||
when {
|
||||
branch 'master'
|
||||
}
|
||||
steps {
|
||||
echo "Current build result: ${currentBuild.result}"
|
||||
withAWS(region: 'us-east-1', credentials:'add82375-f3a1-4b2c-bf52-f557247e9c9e') {
|
||||
s3Upload(bucket:"aidancbrady", path:"mekanism/${env.BUILD_ID}", includePathPattern:'**/*', workingDir:'output')
|
||||
}
|
||||
sh "./gradlew curseforge"
|
||||
}
|
||||
}
|
||||
stage('Cleanup') {
|
||||
steps{
|
||||
dir('output') {
|
||||
deleteDir()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
|
||||
all:
|
||||
./gradlew build
|
||||
|
||||
dev:
|
||||
./gradlew setupDecompWorkspace idea
|
||||
|
||||
clean:
|
||||
rm -rf build .gradle .idea run out *.iml *.ipr *.iws
|
||||
|
||||
rel:
|
||||
docker build -t mekanism .
|
||||
docker run -a stdin -a stdout -a stderr -e CF_API_TOKEN -w /mekanism -it mekanism make docker.rel
|
||||
|
||||
docker.rel:
|
||||
python3 release.py -project 315844 -name MekanismDz -mcvsn 1.12.2 -rel release
|
||||
@@ -19,10 +19,6 @@ buildscript {
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'org.ajoberstar.grgit' version '2.2.0'
|
||||
}
|
||||
|
||||
apply plugin: 'idea'
|
||||
|
||||
defaultTasks 'fullBuild'
|
||||
@@ -109,8 +105,6 @@ configFile.withReader {
|
||||
group = "mekanism-dz"
|
||||
version = "${config.minecraft_version}-${version}"
|
||||
archivesBaseName = "MekanismDzAll"
|
||||
libsDirName = "../output"
|
||||
distsDirName = "../output"
|
||||
sourceCompatibility = '1.8'
|
||||
targetCompatibility = '1.8'
|
||||
|
||||
@@ -286,78 +280,3 @@ uploadArchives {
|
||||
}
|
||||
}
|
||||
|
||||
tasks.curseforge.dependsOn coreJar, toolsJar, generatorsJar, apiJar
|
||||
|
||||
if (System.getenv("CURSEFORGE_KEY") != null || project.hasProperty('curseforgeKey')) {
|
||||
println "Enabling Curseforge config"
|
||||
curseforge {
|
||||
apiKey = System.getenv("CURSEFORGE_KEY") ?: project.findProperty("curseforgeKey")
|
||||
|
||||
def generatedChangelog = "Unable to generate changelog :("
|
||||
def currentCommit = System.getenv("GIT_COMMIT")
|
||||
def prevCommit = System.getenv("GIT_PREVIOUS_SUCCESSFUL_COMMIT") ?: System.getenv("GIT_PREVIOUS_COMMIT")
|
||||
|
||||
if (currentCommit != null && prevCommit != null) {
|
||||
generatedChangelog = "<pre>"
|
||||
grgit.log {
|
||||
range(prevCommit, currentCommit)
|
||||
}.reverse().each { commit ->
|
||||
String message = commit.shortMessage
|
||||
if (!message.startsWith("Merge branch") && !message.startsWith("Merge pull request")) {//Ignore PRs and Merges
|
||||
message = message.replaceAll("#(\\d+)", {match->//turn issues/prs into links (github currently supports prs being linked as issues)
|
||||
return "<a href=\"https://github.com/aidancbrady/Mekanism/issues/${match[1]}\">${match[0]}</a>"
|
||||
})
|
||||
generatedChangelog += "<a href=\"https://github.com/aidancbrady/Mekanism/commit/${commit.id}\">${commit.getAbbreviatedId()}</a> - ${message}\n"
|
||||
}
|
||||
}
|
||||
generatedChangelog += "</pre>"
|
||||
println "Changelog generated"
|
||||
}
|
||||
|
||||
//Core
|
||||
project {
|
||||
id = '268560'
|
||||
changelogType = "html"
|
||||
changelog = generatedChangelog
|
||||
// A file can also be set using: changelog = file('changelog.txt')
|
||||
releaseType = 'release'
|
||||
mainArtifact coreJar
|
||||
addArtifact apiJar
|
||||
addGameVersion '1.12'
|
||||
addGameVersion '1.12.1'
|
||||
addGameVersion '1.12.2'
|
||||
}
|
||||
|
||||
//Tools
|
||||
project {
|
||||
id = '268567'
|
||||
changelogType = "html"
|
||||
changelog = generatedChangelog
|
||||
releaseType = 'release'
|
||||
mainArtifact(toolsJar){
|
||||
relations {
|
||||
requiredLibrary "mekanism"
|
||||
}
|
||||
}
|
||||
addGameVersion '1.12'
|
||||
addGameVersion '1.12.1'
|
||||
addGameVersion '1.12.2'
|
||||
}
|
||||
|
||||
//Generators
|
||||
project {
|
||||
id = '268566'
|
||||
changelogType = "html"
|
||||
changelog = generatedChangelog
|
||||
releaseType = 'release'
|
||||
mainArtifact(generatorsJar) {
|
||||
relations {
|
||||
requiredLibrary "mekanism"
|
||||
}
|
||||
}
|
||||
addGameVersion '1.12'
|
||||
addGameVersion '1.12.1'
|
||||
addGameVersion '1.12.2'
|
||||
}
|
||||
}
|
||||
}
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
|
||||
import os
|
||||
import json
|
||||
import argparse
|
||||
import subprocess
|
||||
import requests
|
||||
import sys
|
||||
import logging
|
||||
|
||||
# These two lines enable debugging at httplib level (requests->urllib3->http.client)
|
||||
# You will see the REQUEST, including HEADERS and DATA, and RESPONSE with HEADERS but without DATA.
|
||||
# The only thing missing will be the response.body which is not logged.
|
||||
# try:
|
||||
# import http.client as http_client
|
||||
# except ImportError:
|
||||
# # Python 2
|
||||
# import httplib as http_client
|
||||
# http_client.HTTPConnection.debuglevel = 1
|
||||
|
||||
# # You must initialize logging, otherwise you'll not see debug output.
|
||||
# logging.basicConfig()
|
||||
# logging.getLogger().setLevel(logging.DEBUG)
|
||||
# requests_log = logging.getLogger("requests.packages.urllib3")
|
||||
# requests_log.setLevel(logging.DEBUG)
|
||||
# requests_log.propagate = True
|
||||
|
||||
#########################################################
|
||||
|
||||
def run(cmd):
|
||||
process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
||||
(output, _err) = process.communicate()
|
||||
if process.returncode != 0:
|
||||
return None, process.returncode
|
||||
return output.strip().decode(), None
|
||||
|
||||
def runNoOutput(cmd):
|
||||
process = subprocess.Popen(cmd)
|
||||
process.communicate()
|
||||
if process.returncode == 0:
|
||||
return None
|
||||
else:
|
||||
return process.returncode
|
||||
|
||||
# Uploading to CF requires a API token (CF_API_TOKEN)
|
||||
apiToken = os.getenv("CF_API_TOKEN")
|
||||
if apiToken == None or len(apiToken) < 1:
|
||||
print("No CF_API_TOKEN available!")
|
||||
sys.exit(1)
|
||||
|
||||
headers = {'X-Api-Token': apiToken}
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("-project", help="Mod project ID", required=True)
|
||||
parser.add_argument("-name", help="Mod filename", required=True)
|
||||
parser.add_argument("-tag", help="Tag to use for this release", default="")
|
||||
parser.add_argument("-mcvsn", help="Game version supported by this release", default="1.12.2")
|
||||
parser.add_argument("-rel", help="Release type (alpha|beta|release)", default="alpha")
|
||||
parser.add_argument("-skipupload", help="Skip uploading to CF", default=False)
|
||||
args = parser.parse_args()
|
||||
|
||||
# Pull the list of game versions
|
||||
versionsReq = requests.get("https://minecraft.curseforge.com/api/game/versions", headers=headers)
|
||||
versions = {}
|
||||
for obj in versionsReq.json():
|
||||
versions[obj["name"]] = obj["id"]
|
||||
|
||||
# Translate requested versions to game version IDs
|
||||
gameId = [versions[args.mcvsn]]
|
||||
|
||||
# If no tag was provided, use the last one on the repo
|
||||
if args.tag == "":
|
||||
args.tag, err = run(["git", "describe", "--abbrev=0", "--tags"])
|
||||
if err != None:
|
||||
print("Failed to find most recent tag!")
|
||||
sys.exit(1)
|
||||
|
||||
print(args.tag)
|
||||
|
||||
# Checkout the appropriate release from git
|
||||
_, err = run(["git", "checkout", "-qf", args.tag])
|
||||
if err != None:
|
||||
print("Failed to checkout tag %s" % (args.tag))
|
||||
sys.exit(1)
|
||||
|
||||
# Get the tag preceding the requested one
|
||||
lastTag, err = run(["git", "describe", "--abbrev=0", "--tags", args.tag+"^"])
|
||||
if err != None:
|
||||
print("Failed to get tag preceding %s" % (args.tag))
|
||||
sys.exit(1)
|
||||
|
||||
# Pull the changelog between the two tags
|
||||
changelog, err = run(["git", "log", "--format=%h: %s", lastTag + ".." + args.tag])
|
||||
if err != None:
|
||||
print("Failed to get changelog for %s -> %s" % (lastTag, args.tag))
|
||||
sys.exit(1)
|
||||
|
||||
# Do the actual build
|
||||
err = runNoOutput(["./gradlew", "-Pversion=" + args.tag, "clean", "build"])
|
||||
if err != None:
|
||||
print(err)
|
||||
print("Build of %s tag failed" % (args.tag))
|
||||
sys.exit(1)
|
||||
|
||||
# Setup metadata field of our POST
|
||||
metadata = json.dumps({"changelog": changelog, "gameVersions": gameId, "releaseType": args.rel})
|
||||
filename = "build/libs/%s-%s-%s.jar" % (args.name, args.mcvsn, args.tag)
|
||||
|
||||
if args.skipupload:
|
||||
print("Skipping upload!")
|
||||
print("Metadata: %s" % metadata)
|
||||
print("Filename: %s" % filename)
|
||||
sys.exit(0)
|
||||
|
||||
# Setup files list for POST
|
||||
files = [('metadata', (None, metadata, "application/json")),
|
||||
('file', (open(filename, "rb")))]
|
||||
resp = requests.post("https://minecraft.curseforge.com/api/projects/%s/upload-file" % args.project, headers=headers, files=files)
|
||||
print(resp.text)
|
||||
resp.raise_for_status()
|
||||
|
||||
|
||||
Reference in new issue
Block a user