mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2024-12-03 16:03:38 +01:00
chore(ci): Swapping build pipeline
This commit is contained in:
parent
b1be39b908
commit
bfea4b2836
32
.autorc
Normal file
32
.autorc
Normal file
@ -0,0 +1,32 @@
|
||||
{
|
||||
"baseBranch": "spigot-1.13-1.16",
|
||||
"plugins": [
|
||||
[
|
||||
"gradle",
|
||||
{
|
||||
"gradleCommand": "./gradlew",
|
||||
"gradleOptions": [""]
|
||||
}
|
||||
],
|
||||
[
|
||||
"exec",
|
||||
{
|
||||
"canary": "./gradlew build discord"
|
||||
}
|
||||
],
|
||||
["conventional-commits", { "preset": "angular" }],
|
||||
"released",
|
||||
["upload-assets", ["./build/libs/*.jar"]]
|
||||
],
|
||||
"owner": "sekwah41",
|
||||
"repo": "Advanced-Portals",
|
||||
"name": "Sekwah",
|
||||
"email": "contact@sekwah.com",
|
||||
"onlyPublishWithReleaseLabel": true,
|
||||
"shipit": {
|
||||
"onlyGraduateWithReleaseLabel": true
|
||||
},
|
||||
"canary": {
|
||||
"message": "📦 Published PR to [discord](https://discord.sekwah.com/) as canary version: %v"
|
||||
}
|
||||
}
|
49
.github/workflows/gradle.yml
vendored
49
.github/workflows/gradle.yml
vendored
@ -1,12 +1,6 @@
|
||||
name: Build Project
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- '**'
|
||||
tags:
|
||||
- '*'
|
||||
pull_request:
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@ -15,26 +9,39 @@ jobs:
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK 8
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: 'zulu'
|
||||
java-version: '8.0'
|
||||
- name: Cache Gradle packages
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.gradle/caches
|
||||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
|
||||
restore-keys: ${{ runner.os }}-gradle
|
||||
- name: Cache Node packages
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: node_modules
|
||||
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
|
||||
restore-keys: ${{ runner.os }}-node
|
||||
- name: Set up JDK 8
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: 'zulu'
|
||||
java-version: 8
|
||||
- name: Use Node.js 12.x
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 12.x
|
||||
- name: Prepare repository
|
||||
run: |
|
||||
git fetch --unshallow --tags
|
||||
yarn install --frozen-lockfile
|
||||
echo $(yarn bin) >> $GITHUB_PATH
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build
|
||||
- name: Upload to Discord (If pre-release tag)
|
||||
if: "startsWith(github.ref, 'refs/tags/v') && contains(github.ref, '-')"
|
||||
env:
|
||||
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
|
||||
run: ./gradlew discordupload
|
||||
- name: Publish to Curseforge (If release tag)
|
||||
if: "startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '-')"
|
||||
- name: Create Release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
CURSE_API: ${{ secrets.CURSE_API }}
|
||||
run: ./gradlew curseforge
|
||||
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
|
||||
run: |
|
||||
npx auto shipit -v
|
||||
|
||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -7,10 +7,11 @@
|
||||
*.war
|
||||
*.ear
|
||||
|
||||
node_modules/
|
||||
*.iml
|
||||
*.iws
|
||||
*.ipr
|
||||
|
||||
.env
|
||||
out/
|
||||
logs/
|
||||
classes/
|
||||
|
@ -1,51 +0,0 @@
|
||||
let versionRegex = /(\nversion:\s)([0-9.-]+)/;
|
||||
let velocityVersionRegex = /(\sversion\s=\s")([0-9.-]+)("\))/;
|
||||
|
||||
|
||||
const ymlUpdater = {
|
||||
updater: {
|
||||
'readVersion': (contents) => {
|
||||
return versionRegex.exec(contents)[2];
|
||||
},
|
||||
'writeVersion': (contents, version) => {
|
||||
return contents.replace(versionRegex, `$1${version}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const bungee = {
|
||||
filename: 'src/main/resources/bungee.yml',
|
||||
...ymlUpdater,
|
||||
}
|
||||
|
||||
const plugin = {
|
||||
filename: 'src/main/resources/plugin.yml',
|
||||
...ymlUpdater,
|
||||
}
|
||||
|
||||
const velocity_plugin = {
|
||||
filename: 'src/main/java/com/sekwah/advancedportals/velocity/AdvancedPortalsPlugin.java',
|
||||
updater: {
|
||||
'readVersion': (contents) => {
|
||||
return velocityVersionRegex.exec(contents)[2];
|
||||
},
|
||||
'writeVersion': (contents, version) => {
|
||||
return contents.replace(velocityVersionRegex, `$1${version}$3`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const files = [plugin, velocity_plugin, bungee];
|
||||
|
||||
module.exports = {
|
||||
bumpFiles: files,
|
||||
packageFiles: files,
|
||||
// In case you need to force a version change (mostly due to change of scope of the update e.g. major now instead of patch)
|
||||
//releaseAs: '0.16.0',
|
||||
header:"# Changelog\n" +
|
||||
"\n" +
|
||||
"All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.\n" +
|
||||
"\n" +
|
||||
"For the release changelogs see [CHANGELOG.md](CHANGELOG.md) \n" +
|
||||
"For the snapshot changelogs see [SNAPSHOT_CHANGELOG.md](SNAPSHOT_CHANGELOG.md)\n",
|
||||
}
|
@ -33,6 +33,10 @@ Usage stats can be found here https://bstats.org/plugin/bukkit/AdvancedPortals
|
||||
The api isn't implemented in this version, sorry for any inconvenience. Check the recode tree for possibly a working recode at some point.
|
||||
|
||||
# Contributing
|
||||
|
||||
Don't worry about updating the file numbers in `bungee.yml`, `plugin.yml` and `AdvancedPortalsPlugin.java`.
|
||||
They will be updated automatically before builds.
|
||||
|
||||
Please ensure that your commits are in the following style for PR's
|
||||
|
||||
https://www.conventionalcommits.org/en/v1.0.0/
|
||||
|
163
build.gradle
163
build.gradle
@ -1,3 +1,4 @@
|
||||
import com.google.gson.Gson
|
||||
import org.apache.commons.codec.Charsets
|
||||
import org.apache.http.HttpEntity
|
||||
import org.apache.http.HttpResponse
|
||||
@ -5,23 +6,20 @@ import org.apache.http.client.HttpClient
|
||||
import org.apache.http.client.config.CookieSpecs
|
||||
import org.apache.http.client.config.RequestConfig
|
||||
import org.apache.http.client.methods.CloseableHttpResponse
|
||||
import org.apache.http.client.methods.HttpGet
|
||||
import org.apache.http.client.methods.HttpPost
|
||||
import org.apache.http.entity.ContentType
|
||||
import org.apache.http.entity.mime.MultipartEntityBuilder
|
||||
import org.apache.http.impl.client.CloseableHttpClient
|
||||
import org.apache.http.impl.client.HttpClientBuilder
|
||||
import org.apache.http.impl.client.HttpClients
|
||||
import org.apache.http.client.methods.HttpGet
|
||||
import com.google.gson.Gson
|
||||
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'maven-publish'
|
||||
apply plugin: 'idea'
|
||||
import java.util.regex.Matcher
|
||||
import java.util.regex.Pattern
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
maven {url "https://plugins.gradle.org/m2/"}
|
||||
maven { url "https://plugins.gradle.org/m2/" }
|
||||
mavenCentral()
|
||||
mavenLocal()
|
||||
jcenter()
|
||||
@ -33,12 +31,20 @@ buildscript {
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'net.researchgate.release' version '2.8.1'
|
||||
}
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'idea'
|
||||
|
||||
def branch = System.getenv("GITHUB_REF");
|
||||
def sha = System.getenv("GITHUB_SHA");
|
||||
def isDevBranch = branch == null || !(branch.startsWith("refs/tags/") && !branch.contains("-"))
|
||||
if (branch != null) {
|
||||
branch = branch.replace('refs/heads/', '')
|
||||
}
|
||||
def isCanary = version.toString().contains('canary')
|
||||
|
||||
group = 'com.sekwah.advancedportals'
|
||||
version = getPluginData("version") + (isDevBranch ? '-SNAPSHOT' : '')
|
||||
|
||||
description = ""
|
||||
|
||||
@ -52,9 +58,9 @@ tasks.withType(JavaCompile) {
|
||||
String getPluginData(String tag) {
|
||||
File file = file("src/main/resources/plugin.yml")
|
||||
String version = "notfound"
|
||||
file.readLines("UTF-8").each {String line ->
|
||||
file.readLines("UTF-8").each { String line ->
|
||||
line = line.trim()
|
||||
if(line.startsWith(tag)) {
|
||||
if (line.startsWith(tag)) {
|
||||
version = line.substring(tag.length() + 2, line.length())
|
||||
}
|
||||
}
|
||||
@ -101,15 +107,20 @@ task discordupload {
|
||||
doLast {
|
||||
String discordWebhook = System.getenv("DISCORD_WEBHOOK")
|
||||
|
||||
if(discordWebhook != null) {
|
||||
if (discordWebhook != null) {
|
||||
println("Logging Into Discord")
|
||||
|
||||
CloseableHttpClient httpClient = HttpClients.createDefault()
|
||||
HttpPost uploadFile = new HttpPost(discordWebhook)
|
||||
|
||||
MultipartEntityBuilder builder = MultipartEntityBuilder.create()
|
||||
builder.addTextBody("content", "New automated dev build\n\n" +
|
||||
"Current Features: <${project.github}/blob/${sha}/docs/SNAPSHOT_CHANGELOG.md>")
|
||||
|
||||
if (isCanary) {
|
||||
builder.addTextBody("content", "New canary Build")
|
||||
} else {
|
||||
builder.addTextBody("content", "New release build\n\n" +
|
||||
"Current Features: <${project.github}/blob/${branch}/CHANGELOG.md>")
|
||||
}
|
||||
|
||||
builder.addBinaryBody("file", file(jar.archiveFile).newInputStream(), ContentType.APPLICATION_OCTET_STREAM, jar.archiveName)
|
||||
|
||||
@ -204,7 +215,7 @@ class GameVersion {
|
||||
|
||||
/**
|
||||
* As described here https://support.curseforge.com/en/support/solutions/articles/9000197321-curseforge-api
|
||||
*/
|
||||
*/
|
||||
class Metadata {
|
||||
String changelog
|
||||
String changelogType
|
||||
@ -227,9 +238,9 @@ task curseforge {
|
||||
apiKey = System.getenv("CURSE_API")
|
||||
}
|
||||
|
||||
if(apiKey != null) {
|
||||
if (apiKey != null) {
|
||||
|
||||
Gson gson = new Gson()
|
||||
Gson gson = new Gson()
|
||||
|
||||
//String VERSION_TYPES_URL = "/api/game/version-types"
|
||||
int gameVersionTypeID = 1
|
||||
@ -239,17 +250,17 @@ task curseforge {
|
||||
// Get game versions
|
||||
String gameVersionsString = getValueFromCurseAPI(apiKey, VERSION_URL)
|
||||
GameVersion[] gameVersions = gson.fromJson(gameVersionsString, GameVersion[].class)
|
||||
def versions = gameVersions.findAll {it.gameVersionTypeID == gameVersionTypeID}
|
||||
def versions = gameVersions.findAll { it.gameVersionTypeID == gameVersionTypeID }
|
||||
|
||||
String[] supportedVersions = [
|
||||
"1.16",
|
||||
"1.15",
|
||||
"1.14",
|
||||
"1.13"
|
||||
"1.16",
|
||||
"1.15",
|
||||
"1.14",
|
||||
"1.13"
|
||||
]
|
||||
|
||||
def supportedGameVersions = versions.findAll {supportedVersions.contains(it.name)}
|
||||
int[] supportedGameVersionIds = supportedGameVersions.collect {it.id}.toArray()
|
||||
def supportedGameVersions = versions.findAll { supportedVersions.contains(it.name) }
|
||||
int[] supportedGameVersionIds = supportedGameVersions.collect { it.id }.toArray()
|
||||
|
||||
println("Supported Version Id's ${supportedGameVersionIds}")
|
||||
|
||||
@ -280,7 +291,7 @@ task curseforge {
|
||||
task copyPlugin {
|
||||
doLast {
|
||||
copy {
|
||||
if(System.env.MC_SERVER_LOC == null) {
|
||||
if (System.env.MC_SERVER_LOC == null) {
|
||||
throw new Exception('You must set the server location and jar to use')
|
||||
}
|
||||
println "$buildDir/libs/Advanced-Portals-${version}.jar"
|
||||
@ -290,7 +301,7 @@ task copyPlugin {
|
||||
include "*.jar"
|
||||
}
|
||||
}
|
||||
catch(RuntimeException e) {
|
||||
catch (RuntimeException e) {
|
||||
println e.getLocalizedMessage()
|
||||
}
|
||||
from file("$buildDir/libs/Advanced-Portals-${version}.jar")
|
||||
@ -303,7 +314,7 @@ task copyPlugin {
|
||||
// DIReallyKnowWhatIAmDoingISwear is to remove the stupid pause spigot has at the start
|
||||
task runJar() {
|
||||
doLast {
|
||||
if(System.env.MC_SERVER_LOC == null || System.env.MC_SERVER_JAR == null) {
|
||||
if (System.env.MC_SERVER_LOC == null || System.env.MC_SERVER_JAR == null) {
|
||||
throw new Exception('You must set the server location and jar to use MC_SERVER_LOC and MC_SERVER_JAR')
|
||||
}
|
||||
javaexec {
|
||||
@ -315,42 +326,76 @@ task runJar() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* These are needed as standard-version doesnt allow for the ability to skip tag versions for the changelog.
|
||||
* Well it does but not on purpose and it breaks things.
|
||||
*
|
||||
* Tagging is skipped so that the release can be merged and confirmed (A little long winded but just to stop mistakes)
|
||||
*/
|
||||
task updateChangelog {
|
||||
doLast{
|
||||
exec {
|
||||
commandLine 'cmd', '/c', 'npx standard-version@9.3.0 -i docs/CHANGELOG.md -t (v)[0-9]+.[0-0]+.[0-0]+(?!-) --skip.tag'
|
||||
ext.output = {
|
||||
return standardOutput.toString()
|
||||
}
|
||||
}
|
||||
exec {
|
||||
commandLine 'cmd', '/c', 'npx standard-version@9.3.0 --skip.changelog --skip.bump --skip.tag'
|
||||
ext.output = {
|
||||
return standardOutput.toString()
|
||||
}
|
||||
}
|
||||
task publish {
|
||||
doLast {
|
||||
println "This is a dummy task to run others for version: ${version}"
|
||||
}
|
||||
}
|
||||
|
||||
task updateChangelogPreRelease(type: Exec) {
|
||||
commandLine 'cmd', '/c', 'npx standard-version@9.3.0 --prerelease -i docs/SNAPSHOT_CHANGELOG.md --skip.tag'
|
||||
ext.output = {
|
||||
return standardOutput.toString()
|
||||
// https://github.com/researchgate/gradle-release
|
||||
// Only other plugin I can find using auto & gradle https://github.com/intuit/hooks
|
||||
release {
|
||||
failOnPublishNeeded = false
|
||||
failOnSnapshotDependencies = false
|
||||
git {
|
||||
requireBranch = ''
|
||||
}
|
||||
|
||||
|
||||
// Disable tasks because something we have is causing -x to be ignored
|
||||
createReleaseTag.enabled = false
|
||||
preTagCommit.enabled = false
|
||||
commitNewVersion.enabled = false
|
||||
}
|
||||
|
||||
task cleanbuildfolder {
|
||||
doFirst {
|
||||
println "Cleaning up previous builds (to stop publishing old ones by mistake)"
|
||||
project.delete(files("${buildDir}/libs"))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Just to stop having to manually tagging. Probably could do this easier but meh stops typos or other issues.
|
||||
*/
|
||||
task tagRelease(type: Exec) {
|
||||
commandLine 'cmd', '/c', 'npx standard-version@9.3.0 --prerelease -i docs/SNAPSHOT_CHANGELOG.md --skip.changelog --skip.bump'
|
||||
ext.output = {
|
||||
return standardOutput.toString()
|
||||
void updateFileVersion(String fileLoc, Pattern pattern, Closure<String> stringClosure) {
|
||||
File file = new File(projectDir, fileLoc)
|
||||
Matcher m = pattern.matcher(file.text)
|
||||
if (m.find()) {
|
||||
def newVersion = stringClosure.call(m)
|
||||
println "Replacing ${pattern.toString()} in ${fileLoc} with '${newVersion}'"
|
||||
file.text = file.text.replaceAll(pattern, newVersion)
|
||||
}
|
||||
}
|
||||
|
||||
// Just to keep all numbers the same (as they are dotted all over the place)
|
||||
task updateVersionNumbers {
|
||||
doFirst {
|
||||
def versionRegex = ~/(\nversion:\s)([0-9.-]+)/
|
||||
def velocityVersionRegex = ~/(\sversion\s=\s")([0-9.-]+)("\))/
|
||||
|
||||
updateFileVersion("src/main/resources/bungee.yml", versionRegex,
|
||||
{ Matcher m ->
|
||||
return "${m.group(1)}${getVersion()}"
|
||||
})
|
||||
|
||||
updateFileVersion("src/main/resources/plugin.yml", versionRegex,
|
||||
{ Matcher m ->
|
||||
return "${m.group(1)}${getVersion()}"
|
||||
})
|
||||
|
||||
updateFileVersion("src/main/java/com/sekwah/advancedportals/velocity/AdvancedPortalsPlugin.java",
|
||||
velocityVersionRegex,
|
||||
{ Matcher m ->
|
||||
return "${m.group(1)}${getVersion()}${m.group(3)}"
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
compileJava.dependsOn 'cleanbuildfolder'
|
||||
compileJava.dependsOn 'updateVersionNumbers'
|
||||
|
||||
// Publish rules
|
||||
// Current behavior seems to be canary or release. Though pre-releases may break this pattern.
|
||||
publish.dependsOn 'build'
|
||||
publish.finalizedBy 'discordupload'
|
||||
if (!isCanary) {
|
||||
publish.finalizedBy 'curseforge'
|
||||
}
|
||||
|
@ -1,26 +0,0 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
|
||||
For the release changelogs see [CHANGELOG.md](CHANGELOG.md)
|
||||
For the snapshot changelogs see [SNAPSHOT_CHANGELOG.md](SNAPSHOT_CHANGELOG.md)
|
||||
|
||||
### [0.5.13-2](https://github.com/sekwah41/Advanced-Portals/compare/v0.5.13-1...v0.5.13-2) (2021-05-14)
|
||||
|
||||
* No code changes, just updated the changelog generation.
|
||||
|
||||
### 0.5.13-1 (2021-05-12)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* Added configurable proxy teleport delay ([a1121ad](https://github.com/sekwah41/Advanced-Portals/commit/a1121adc10addfcce515d1358d1274232109fdfd))
|
||||
|
||||
### 0.5.13-0 (2021-05-12)
|
||||
|
||||
* Build Tool Change: Updated versioning and changelog tooling and standards.
|
||||
* Added improved support for Velocity (You can now add it directly to Velocity as a plugin)
|
||||
* Added a ForceEnableProxySupport config option in case any are not detected
|
||||
* Modern forwarding will be automatically detected. You will no longer need to manually set ForceEnableProxySupport
|
||||
|
||||
|
@ -4,3 +4,4 @@ org.gradle.caching=true
|
||||
|
||||
github=https://github.com/sekwah41/Advanced-Portals
|
||||
curse_project_id=86001
|
||||
version=0.6.1
|
||||
|
12
package.json
Normal file
12
package.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"devDependencies": {
|
||||
"conventional-changelog-angular": "5.0.12",
|
||||
"@auto-it/conventional-commits": "^10.29.3",
|
||||
"@auto-it/exec": "^10.29.3",
|
||||
"@auto-it/first-time-contributor": "^10.29.3",
|
||||
"@auto-it/gradle": "^10.29.3",
|
||||
"@auto-it/released": "^10.29.3",
|
||||
"@auto-it/upload-assets": "^10.29.3",
|
||||
"auto": "^10.29.3"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user