chore(ci): Swapping build pipeline

This commit is contained in:
Sekwah 2021-06-27 17:34:33 +01:00
parent b1be39b908
commit bfea4b2836
No known key found for this signature in database
GPG Key ID: B506846B1ED62854
11 changed files with 2831 additions and 158 deletions

32
.autorc Normal file
View 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"
}
}

View File

@ -1,12 +1,6 @@
name: Build Project name: Release
on: on: [push]
push:
branches:
- '**'
tags:
- '*'
pull_request:
jobs: jobs:
build: build:
@ -15,26 +9,39 @@ jobs:
steps: steps:
- uses: actions/checkout@v2 - 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 - name: Cache Gradle packages
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: ~/.gradle/caches path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-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 - name: Build with Gradle
run: ./gradlew build run: ./gradlew build
- name: Upload to Discord (If pre-release tag) - name: Create Release
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, '-')"
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CURSE_API: ${{ secrets.CURSE_API }} CURSE_API: ${{ secrets.CURSE_API }}
run: ./gradlew curseforge DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
run: |
npx auto shipit -v

3
.gitignore vendored
View File

@ -7,10 +7,11 @@
*.war *.war
*.ear *.ear
node_modules/
*.iml *.iml
*.iws *.iws
*.ipr *.ipr
.env
out/ out/
logs/ logs/
classes/ classes/

View File

@ -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",
}

View File

@ -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. 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 # 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 Please ensure that your commits are in the following style for PR's
https://www.conventionalcommits.org/en/v1.0.0/ https://www.conventionalcommits.org/en/v1.0.0/

View File

@ -1,3 +1,4 @@
import com.google.gson.Gson
import org.apache.commons.codec.Charsets import org.apache.commons.codec.Charsets
import org.apache.http.HttpEntity import org.apache.http.HttpEntity
import org.apache.http.HttpResponse 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.CookieSpecs
import org.apache.http.client.config.RequestConfig import org.apache.http.client.config.RequestConfig
import org.apache.http.client.methods.CloseableHttpResponse 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.client.methods.HttpPost
import org.apache.http.entity.ContentType import org.apache.http.entity.ContentType
import org.apache.http.entity.mime.MultipartEntityBuilder import org.apache.http.entity.mime.MultipartEntityBuilder
import org.apache.http.impl.client.CloseableHttpClient import org.apache.http.impl.client.CloseableHttpClient
import org.apache.http.impl.client.HttpClientBuilder import org.apache.http.impl.client.HttpClientBuilder
import org.apache.http.impl.client.HttpClients import org.apache.http.impl.client.HttpClients
import org.apache.http.client.methods.HttpGet
import com.google.gson.Gson
import java.util.regex.Matcher
apply plugin: 'java' import java.util.regex.Pattern
apply plugin: 'maven-publish'
apply plugin: 'idea'
buildscript { buildscript {
repositories { repositories {
maven {url "https://plugins.gradle.org/m2/"} maven { url "https://plugins.gradle.org/m2/" }
mavenCentral() mavenCentral()
mavenLocal() mavenLocal()
jcenter() 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 branch = System.getenv("GITHUB_REF");
def sha = System.getenv("GITHUB_SHA"); if (branch != null) {
def isDevBranch = branch == null || !(branch.startsWith("refs/tags/") && !branch.contains("-")) branch = branch.replace('refs/heads/', '')
}
def isCanary = version.toString().contains('canary')
group = 'com.sekwah.advancedportals' group = 'com.sekwah.advancedportals'
version = getPluginData("version") + (isDevBranch ? '-SNAPSHOT' : '')
description = "" description = ""
@ -52,9 +58,9 @@ tasks.withType(JavaCompile) {
String getPluginData(String tag) { String getPluginData(String tag) {
File file = file("src/main/resources/plugin.yml") File file = file("src/main/resources/plugin.yml")
String version = "notfound" String version = "notfound"
file.readLines("UTF-8").each {String line -> file.readLines("UTF-8").each { String line ->
line = line.trim() line = line.trim()
if(line.startsWith(tag)) { if (line.startsWith(tag)) {
version = line.substring(tag.length() + 2, line.length()) version = line.substring(tag.length() + 2, line.length())
} }
} }
@ -101,15 +107,20 @@ task discordupload {
doLast { doLast {
String discordWebhook = System.getenv("DISCORD_WEBHOOK") String discordWebhook = System.getenv("DISCORD_WEBHOOK")
if(discordWebhook != null) { if (discordWebhook != null) {
println("Logging Into Discord") println("Logging Into Discord")
CloseableHttpClient httpClient = HttpClients.createDefault() CloseableHttpClient httpClient = HttpClients.createDefault()
HttpPost uploadFile = new HttpPost(discordWebhook) HttpPost uploadFile = new HttpPost(discordWebhook)
MultipartEntityBuilder builder = MultipartEntityBuilder.create() 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) 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 * As described here https://support.curseforge.com/en/support/solutions/articles/9000197321-curseforge-api
*/ */
class Metadata { class Metadata {
String changelog String changelog
String changelogType String changelogType
@ -227,9 +238,9 @@ task curseforge {
apiKey = System.getenv("CURSE_API") 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" //String VERSION_TYPES_URL = "/api/game/version-types"
int gameVersionTypeID = 1 int gameVersionTypeID = 1
@ -239,17 +250,17 @@ task curseforge {
// Get game versions // Get game versions
String gameVersionsString = getValueFromCurseAPI(apiKey, VERSION_URL) String gameVersionsString = getValueFromCurseAPI(apiKey, VERSION_URL)
GameVersion[] gameVersions = gson.fromJson(gameVersionsString, GameVersion[].class) GameVersion[] gameVersions = gson.fromJson(gameVersionsString, GameVersion[].class)
def versions = gameVersions.findAll {it.gameVersionTypeID == gameVersionTypeID} def versions = gameVersions.findAll { it.gameVersionTypeID == gameVersionTypeID }
String[] supportedVersions = [ String[] supportedVersions = [
"1.16", "1.16",
"1.15", "1.15",
"1.14", "1.14",
"1.13" "1.13"
] ]
def supportedGameVersions = versions.findAll {supportedVersions.contains(it.name)} def supportedGameVersions = versions.findAll { supportedVersions.contains(it.name) }
int[] supportedGameVersionIds = supportedGameVersions.collect {it.id}.toArray() int[] supportedGameVersionIds = supportedGameVersions.collect { it.id }.toArray()
println("Supported Version Id's ${supportedGameVersionIds}") println("Supported Version Id's ${supportedGameVersionIds}")
@ -280,7 +291,7 @@ task curseforge {
task copyPlugin { task copyPlugin {
doLast { doLast {
copy { 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') throw new Exception('You must set the server location and jar to use')
} }
println "$buildDir/libs/Advanced-Portals-${version}.jar" println "$buildDir/libs/Advanced-Portals-${version}.jar"
@ -290,7 +301,7 @@ task copyPlugin {
include "*.jar" include "*.jar"
} }
} }
catch(RuntimeException e) { catch (RuntimeException e) {
println e.getLocalizedMessage() println e.getLocalizedMessage()
} }
from file("$buildDir/libs/Advanced-Portals-${version}.jar") 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 // DIReallyKnowWhatIAmDoingISwear is to remove the stupid pause spigot has at the start
task runJar() { task runJar() {
doLast { 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') throw new Exception('You must set the server location and jar to use MC_SERVER_LOC and MC_SERVER_JAR')
} }
javaexec { javaexec {
@ -315,42 +326,76 @@ task runJar() {
} }
} }
/** task publish {
* These are needed as standard-version doesnt allow for the ability to skip tag versions for the changelog. doLast {
* Well it does but not on purpose and it breaks things. println "This is a dummy task to run others for version: ${version}"
*
* 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 updateChangelogPreRelease(type: Exec) { // https://github.com/researchgate/gradle-release
commandLine 'cmd', '/c', 'npx standard-version@9.3.0 --prerelease -i docs/SNAPSHOT_CHANGELOG.md --skip.tag' // Only other plugin I can find using auto & gradle https://github.com/intuit/hooks
ext.output = { release {
return standardOutput.toString() 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"))
} }
} }
/** void updateFileVersion(String fileLoc, Pattern pattern, Closure<String> stringClosure) {
* Just to stop having to manually tagging. Probably could do this easier but meh stops typos or other issues. File file = new File(projectDir, fileLoc)
*/ Matcher m = pattern.matcher(file.text)
task tagRelease(type: Exec) { if (m.find()) {
commandLine 'cmd', '/c', 'npx standard-version@9.3.0 --prerelease -i docs/SNAPSHOT_CHANGELOG.md --skip.changelog --skip.bump' def newVersion = stringClosure.call(m)
ext.output = { println "Replacing ${pattern.toString()} in ${fileLoc} with '${newVersion}'"
return standardOutput.toString() 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'
}

View File

@ -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

View File

@ -4,3 +4,4 @@ org.gradle.caching=true
github=https://github.com/sekwah41/Advanced-Portals github=https://github.com/sekwah41/Advanced-Portals
curse_project_id=86001 curse_project_id=86001
version=0.6.1

12
package.json Normal file
View 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"
}
}

2648
yarn.lock Normal file

File diff suppressed because it is too large Load Diff