mirror of
https://github.com/FabricMC/fabric.git
synced 2024-11-23 08:08:02 -05:00
Publish releases using github actions (#1124)
* 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:
parent
6672c51bec
commit
2209e98bb5
7 changed files with 105 additions and 44 deletions
15
.github/workflows/build.yml
vendored
15
.github/workflows/build.yml
vendored
|
@ -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
18
.github/workflows/release.yml
vendored
Normal 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 }}
|
42
build.gradle
42
build.gradle
|
@ -24,7 +24,7 @@ class Globals {
|
|||
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
|
||||
|
@ -44,8 +44,9 @@ def getSubprojectVersion(project, version) {
|
|||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
|
@ -246,12 +247,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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -277,8 +279,8 @@ 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 {
|
||||
|
@ -309,12 +311,12 @@ 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")
|
||||
|
@ -325,3 +327,19 @@ task github(dependsOn: remapMavenJar) {
|
|||
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
|
||||
|
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,5 +1,5 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
51
gradlew
vendored
51
gradlew
vendored
|
@ -1,5 +1,21 @@
|
|||
#!/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.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
|
@ -28,7 +44,7 @@ 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"
|
||||
|
@ -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,19 +154,19 @@ 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
|
||||
|
||||
|
@ -159,14 +175,9 @@ save () {
|
|||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=$(save "$@")
|
||||
APP_ARGS=`save "$@"`
|
||||
|
||||
# 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"
|
||||
|
||||
# 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
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
|
|
21
gradlew.bat
vendored
21
gradlew.bat
vendored
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue