Publish releases using github actions ()

* Publish releases using github actions

* # Conflicts:
#	build.gradle

* Remove build number + add task to check version has not already been released
This commit is contained in:
modmuss50 2020-11-05 18:12:01 +00:00
parent 5452dd0911
commit d5ca230c2d
7 changed files with 164 additions and 87 deletions

View file

@ -4,20 +4,15 @@ jobs:
build:
strategy:
matrix:
java-version: [1.8, 11, 14]
java: [8-jdk, 11-jdk, 15-jdk]
runs-on: ubuntu-20.04
container:
image: openjdk:${{ matrix.java }}
options: --user root
steps:
- uses: actions/checkout@v1
- uses: gradle/wrapper-validation-action@v1
- uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java-version }}
- uses: eskatos/gradle-command-action@v1.3.2
with:
gradle-version: wrapper
arguments: check build publishToMavenLocal --stacktrace --parallel
dependencies-cache-enabled: false
configuration-cache-enabled: false
- run: ./gradlew check build publishToMavenLocal --stacktrace --parallel
- uses: actions/upload-artifact@v2
with:
name: Artifacts

18
.github/workflows/release.yml vendored Normal file
View file

@ -0,0 +1,18 @@
name: Release
on: [workflow_dispatch] # Manual trigger
jobs:
build:
runs-on: ubuntu-20.04
container:
image: openjdk:15-jdk
options: --user root
steps:
- uses: actions/checkout@v1
- uses: gradle/wrapper-validation-action@v1
- run: ./gradlew checkVersion build publish curseforge github --stacktrace
env:
MAVEN_URL: ${{ secrets.MAVEN_URL }}
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View file

@ -5,14 +5,14 @@ buildscript {
}
plugins {
id 'java'
id 'eclipse'
id 'idea'
id 'maven-publish'
id 'fabric-loom' version '0.5.25' apply false
id 'net.minecrell.licenser' version '0.4.1'
id "java"
id "eclipse"
id "idea"
id "maven-publish"
id "fabric-loom" version "0.5.33" apply false
id "net.minecrell.licenser" version "0.4.1"
id "org.ajoberstar.grgit" version "3.1.1"
id 'com.matthewprenger.cursegradle' version "1.4.0"
id "com.matthewprenger.cursegradle" version "1.4.0"
}
def ENV = System.getenv()
@ -21,9 +21,10 @@ class Globals {
static def baseVersion = "0.21.0"
static def mcVersion = "1.15.2"
static def yarnVersion = "+build.1"
static def loaderVersion = "0.10.5+build.213"
}
version = Globals.baseVersion + "+" + (ENV.BUILD_NUMBER ? ("build." + ENV.BUILD_NUMBER) : "local") + "-" + getBranch()
version = Globals.baseVersion + "+" + (ENV.GITHUB_RUN_NUMBER ? "" : "local-") + getBranch()
logger.lifecycle("Building Fabric: " + version)
import org.apache.commons.codec.digest.DigestUtils
@ -35,28 +36,31 @@ def getSubprojectVersion(project, version) {
def latestCommits = grgit.log(paths: [project.name], maxCommits: 1)
if (latestCommits.isEmpty()) {
return version + "+uncommited"
} else {
return version + "+" + latestCommits.get(0).id.substring(0, 8) + DigestUtils.sha256Hex(Globals.mcVersion).substring(0, 2)
}
return version + "+" + latestCommits.get(0).id.substring(0, 8) + DigestUtils.sha256Hex(Globals.mcVersion).substring(0, 2)
}
def getBranch() {
if (System.getenv().GIT_BRANCH) {
def branch = System.getenv().GIT_BRANCH
def ENV = System.getenv()
if (ENV.GITHUB_REF) {
def branch = ENV.GITHUB_REF
return branch.substring(branch.lastIndexOf("/") + 1)
}
if (grgit == null) {
return "unknown"
}
def branch = grgit.branch.current().name
return branch.substring(branch.lastIndexOf("/") + 1)
}
allprojects {
apply plugin: 'checkstyle'
apply plugin: 'maven-publish'
apply plugin: 'fabric-loom'
apply plugin: 'net.minecrell.licenser'
apply plugin: "checkstyle"
apply plugin: "maven-publish"
apply plugin: "fabric-loom"
apply plugin: "net.minecrell.licenser"
sourceCompatibility = 1.8
targetCompatibility = 1.8
@ -73,7 +77,7 @@ allprojects {
dependencies {
minecraft "com.mojang:minecraft:$Globals.mcVersion"
mappings "net.fabricmc:yarn:${Globals.mcVersion}${Globals.yarnVersion}:v2"
modCompile "net.fabricmc:fabric-loader:0.8.2+build.194"
modCompile "net.fabricmc:fabric-loader:${Globals.loaderVersion}"
}
configurations {
@ -116,42 +120,44 @@ allprojects {
}
license {
header rootProject.file('HEADER')
include '**/*.java'
header rootProject.file("HEADER")
include "**/*.java"
}
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
archiveClassifier = "sources"
from sourceSets.main.allSource
}
checkstyle {
configFile = rootProject.file("checkstyle.xml")
toolVersion = '8.31'
toolVersion = "8.31"
}
}
javadoc {
options {
source = "8"
encoding = 'UTF-8'
charSet = 'UTF-8'
encoding = "UTF-8"
charSet = "UTF-8"
memberLevel = JavadocMemberLevel.PACKAGE
links(
'https://guava.dev/releases/21.0/api/docs/',
'https://asm.ow2.io/javadoc/',
'https://docs.oracle.com/javase/8/docs/api/',
'http://jenkins.liteloader.com/job/Mixin/javadoc/',
'https://logging.apache.org/log4j/2.x/log4j-api/apidocs/'
"https://guava.dev/releases/21.0/api/docs/",
"https://asm.ow2.io/javadoc/",
"https://docs.oracle.com/javase/8/docs/api/",
"http://jenkins.liteloader.com/job/Mixin/javadoc/",
"https://logging.apache.org/log4j/2.x/log4j-api/apidocs/"
// Need to add minecraft jd publication etc once there is one available
)
// Disable the crazy super-strict doclint tool in Java 8
addStringOption('Xdoclint:none', '-quiet')
addStringOption("Xdoclint:none", "-quiet")
}
allprojects.each {
source(it.sourceSets.main.allJava.srcDirs)
}
classpath = sourceSets.main.compileClasspath
include("**/api/**")
failOnError false
@ -161,12 +167,12 @@ task javadocJar(type: Jar) {
dependsOn javadoc
from javadoc.destinationDir
//Set as `fatjavadoc` to prevent an ide form trying to use this javadoc, over using the modules javadoc
classifier = 'fatjavadoc'
archiveClassifier = "fatjavadoc"
}
build.dependsOn javadocJar
subprojects {
dependencies {
testmodCompile sourceSets.main.output
}
@ -186,6 +192,7 @@ subprojects {
artifact(file("${project.buildDir}/libs/$archivesBaseName-${version}-maven.jar")) {
builtBy remapMavenJar
}
artifact(sourcesJar) {
builtBy remapSourcesJar
}
@ -213,10 +220,13 @@ publishing {
artifact(file("${project.buildDir}/libs/$archivesBaseName-${version}-maven.jar")) {
builtBy remapMavenJar
}
artifact(sourcesJar) {
builtBy remapSourcesJar
}
artifact javadocJar
pom.withXml {
def depsNode = asNode().appendNode("dependencies")
subprojects.each {
@ -235,12 +245,13 @@ publishing {
void setupRepositories(RepositoryHandler repositories) {
//repositories.mavenLocal() // uncomment for testing
if (project.hasProperty('mavenPass')) {
def ENV = System.getenv()
if (ENV.MAVEN_URL) {
repositories.maven {
url "http://mavenupload.modmuss50.me/"
url ENV.MAVEN_URL
credentials {
username 'buildslave'
password project.getProperty('mavenPass')
username ENV.MAVEN_USERNAME
password ENV.MAVEN_PASSWORD
}
}
}
@ -266,46 +277,67 @@ dependencies {
}
curseforge {
if (project.hasProperty('curse_api_key')) {
apiKey = project.getProperty('curse_api_key')
if (ENV.CURSEFORGE_API_KEY) {
apiKey = ENV.CURSEFORGE_API_KEY
}
project {
id = '306612'
changelog = 'A changelog can be found at https://github.com/FabricMC/fabric/commits'
releaseType = 'release'
addGameVersion '1.15.2'
addGameVersion 'Fabric'
id = "306612"
changelog = "A changelog can be found at https://github.com/FabricMC/fabric/commits"
releaseType = "release"
addGameVersion "1.15.2"
addGameVersion "Fabric"
mainArtifact(file("${project.buildDir}/libs/${archivesBaseName}-${version}.jar")) {
displayName = "[$Globals.mcVersion] Fabric API $Globals.baseVersion build $ENV.BUILD_NUMBER"
}
afterEvaluate {
uploadTask.dependsOn("remapJar")
}
}
options {
forgeGradleIntegration = false
}
}
apply from: 'https://github.com/FabricMC/fabric-docs/raw/master/gradle/ideconfig.gradle'
apply from: "https://github.com/FabricMC/fabric-docs/raw/master/gradle/ideconfig.gradle"
import org.kohsuke.github.GHReleaseBuilder
import org.kohsuke.github.GitHub
task github(dependsOn: remapMavenJar) {
onlyIf {
project.hasProperty('github_api_key')
ENV.GITHUB_TOKEN
}
doLast {
def github = GitHub.connectUsingOAuth(project.getProperty('github_api_key') as String)
def repository = github.getRepository("FabricMC/fabric")
def github = GitHub.connectUsingOAuth(ENV.GITHUB_TOKEN as String)
def repository = github.getRepository(ENV.GITHUB_REPOSITORY)
def releaseBuilder = new GHReleaseBuilder(repository, version as String)
releaseBuilder.name("[$Globals.mcVersion] Fabric API $Globals.baseVersion build $ENV.BUILD_NUMBER")
releaseBuilder.body('A changelog can be found at https://github.com/FabricMC/fabric/commits')
releaseBuilder.body("A changelog can be found at https://github.com/FabricMC/fabric/commits")
releaseBuilder.commitish(getBranch())
def ghRelease = releaseBuilder.create()
ghRelease.uploadAsset(file("${project.buildDir}/libs/${archivesBaseName}-${version}.jar"), "application/java-archive");
}
}
// A task to ensure that the version being released has not already been released.
task checkVersion {
doFirst {
def xml = new URL("https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api/maven-metadata.xml").text
def metadata = new XmlSlurper().parseText(xml)
def versions = metadata.versioning.versions.version*.text();
if (versions.contains(version)) {
throw new RuntimeException("${version} has already been released!")
}
}
}
github.mustRunAfter checkVersion
publish.mustRunAfter checkVersion
project.tasks.curseforge.mustRunAfter checkVersion

Binary file not shown.

View file

@ -1,6 +1,5 @@
#Mon Aug 22 17:36:22 EDT 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip

68
gradlew vendored
View file

@ -1,4 +1,20 @@
#!/usr/bin/env bash
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
@ -28,16 +44,16 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
warn () {
echo "$*"
}
die ( ) {
die () {
echo
echo "$*"
echo
@ -109,8 +125,8 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
@ -138,32 +154,30 @@ if $cygwin ; then
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
i=`expr $i + 1`
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
APP_ARGS=`save "$@"`
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [[ "$(uname)" == "Darwin" ]] && [[ "$HOME" == "$PWD" ]]; then
cd "$(dirname "$0")"
fi
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
exec "$JAVACMD" "$@"

21
gradlew.bat vendored
View file

@ -1,3 +1,19 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@ -13,8 +29,11 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome