Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/upstream/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	Jenkinsfile
  • Loading branch information
Konicai committed May 4, 2024
2 parents 987d918 + a44e3a5 commit eb04c7b
Show file tree
Hide file tree
Showing 48 changed files with 704 additions and 668 deletions.
108 changes: 85 additions & 23 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,107 @@ on: [push]
jobs:
build:
runs-on: ubuntu-latest
env:
PROJECT: 'floodgate'
steps:
- name: Set Build Number
env:
BUILD_JSON: ${{ vars.RELEASEACTION_PREVRELEASE }}
run: |
BUILD_NUMBER=$(echo $BUILD_JSON | jq --arg branch "${GITHUB_REF_NAME}" 'if .[$branch] == null then 1 else .[$branch] | .t | tonumber + 1 end // 1')
echo "BUILD_NUMBER=${BUILD_NUMBER:=$GITHUB_RUN_NUMBER}" >> $GITHUB_ENV
- name: Checkout repository and submodules
uses: actions/checkout@v3
# See https://github.com/actions/checkout/commits
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
submodules: recursive

- uses: actions/setup-java@v3
- name: Validate Gradle Wrapper
# See https://github.com/gradle/wrapper-validation-action/commits
uses: gradle/wrapper-validation-action@699bb18358f12c5b78b37bb0111d3a0e2276e0e2 # v2.1.1

# See https://github.com/actions/setup-java/commits
- uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0
with:
java-version: 17
distribution: temurin

- name: Build
uses: gradle/gradle-build-action@v2
# See https://github.com/gradle/actions/commits
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0
with:
arguments: build
cache-read-only: ${{ github.ref_name != 'master' && github.ref_name != 'development' }}

- name: Archive artifacts (Floodgate Bungee)
# See https://github.com/actions/upload-artifact/commits
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
if: success()
with:
name: Floodgate Bungee
path: bungee/build/libs/floodgate-bungee.jar
if-no-files-found: error

- name: Archive artifacts (Floodgate Spigot)
# See https://github.com/actions/upload-artifact/commits
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
if: success()
with:
name: Floodgate Spigot
path: spigot/build/libs/floodgate-spigot.jar
if-no-files-found: error

- name: Archive artifacts (Floodgate Velocity)
# See https://github.com/actions/upload-artifact/commits
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
if: success()
with:
name: Floodgate Velocity
path: velocity/build/libs/floodgate-velocity.jar
if-no-files-found: error

- name: Publish to Maven Repository
if: ${{ github.repository == 'GeyserMC/Floodgate' }}
uses: gradle/gradle-build-action@v2
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5
env:
ORG_GRADLE_PROJECT_geysermcUsername: ${{ vars.DEPLOY_USER }}
ORG_GRADLE_PROJECT_geysermcPassword: ${{ secrets.DEPLOY_PASS }}
with:
arguments: publish
cache-read-only: ${{ github.ref_name != 'master' && github.ref_name != 'development' }}

- name: Get Release Metadata
if: ${{ success() && github.repository == 'GeyserMC/Floodgate' && github.ref_name == 'master' }}
# See https://github.com/Kas-tle/base-release-action/releases/tag/main-11
uses: Kas-tle/base-release-action@b863fa0f89bd15267a96a72efb84aec25f168d4c # main-11
with:
appID: ${{ secrets.RELEASE_APP_ID }}
appPrivateKey: ${{ secrets.RELEASE_APP_PK }}
files: |
bungee:bungee/build/libs/floodgate-bungee.jar
spigot:spigot/build/libs/floodgate-spigot.jar
velocity:velocity/build/libs/floodgate-velocity.jar
releaseEnabled: false
saveMetadata: true

- name: Update Generated Metadata
if: ${{ success() && github.repository == 'GeyserMC/Floodgate' && github.ref_name == 'master' }}
run: |
cat metadata.json
echo
mv metadata.json metadata.json.tmp
version=$(cat gradle.properties | grep -o "version=[0-9\\.]*" | cut -d"=" -f2)
jq --arg project "${PROJECT}" --arg version "${version}" '
.
| .changes |= map({"commit", "summary", "message"})
| .downloads |= map_values({"name", "sha256"})
| {$project, "repo", $version, "number": .build, "changes", "downloads"}
' metadata.json.tmp > metadata.json
cat metadata.json
- name: Publish to Downloads API
if: ${{ github.ref_name == 'master' && github.repository == 'GeyserMC/Floodgate' }}
if: ${{ success() && github.ref_name == 'master' && github.repository == 'GeyserMC/Floodgate' }}
shell: bash
env:
DOWNLOADS_USERNAME: ${{ vars.DOWNLOADS_USERNAME }}
Expand All @@ -43,28 +115,18 @@ jobs:
# Save the private key to a file
echo "$DOWNLOADS_PRIVATE_KEY" > id_ecdsa
chmod 600 id_ecdsa
# Set the project
project=floodgate
# Get the version from gradle.properties
version=$(cat gradle.properties | grep -o "version=[0-9\\.]*" | cut -d"=" -f2)
# Create the build folder
ssh -o StrictHostKeyChecking=no -i id_ecdsa $DOWNLOADS_USERNAME@$DOWNLOADS_SERVER_IP mkdir -p "~/uploads/$project/$GITHUB_RUN_NUMBER/"
ssh -o StrictHostKeyChecking=no -i id_ecdsa $DOWNLOADS_USERNAME@$DOWNLOADS_SERVER_IP mkdir -p "~/uploads/$PROJECT/$GITHUB_RUN_NUMBER/"
# Copy over artifacts
rsync -P -e "ssh -o StrictHostKeyChecking=no -i id_ecdsa" **/build/libs/floodgate-*.jar $DOWNLOADS_USERNAME@$DOWNLOADS_SERVER_IP:~/uploads/$project/$GITHUB_RUN_NUMBER/
# Remove un-needed artifacts
ssh -o StrictHostKeyChecking=no -i id_ecdsa $DOWNLOADS_USERNAME@$DOWNLOADS_SERVER_IP rm ./uploads/$project/$GITHUB_RUN_NUMBER/floodgate-api.jar ./uploads/$project/$GITHUB_RUN_NUMBER/floodgate-core.jar
# Push the metadata
echo "{\"project\": \"$project\", \"version\": \"$version\", \"id\": $GITHUB_RUN_NUMBER, \"commit\": \"$GITHUB_SHA\"}" > metadata.json
rsync -P -e "ssh -o StrictHostKeyChecking=no -i id_ecdsa" metadata.json $DOWNLOADS_USERNAME@$DOWNLOADS_SERVER_IP:~/uploads/$project/$GITHUB_RUN_NUMBER/
rsync -P -e "ssh -o StrictHostKeyChecking=no -i id_ecdsa" bungee/build/libs/floodgate-bungee.jar $DOWNLOADS_USERNAME@$DOWNLOADS_SERVER_IP:~/uploads/$PROJECT/$GITHUB_RUN_NUMBER/
rsync -P -e "ssh -o StrictHostKeyChecking=no -i id_ecdsa" spigot/build/libs/floodgate-spigot.jar $DOWNLOADS_USERNAME@$DOWNLOADS_SERVER_IP:~/uploads/$PROJECT/$GITHUB_RUN_NUMBER/
rsync -P -e "ssh -o StrictHostKeyChecking=no -i id_ecdsa" velocity/build/libs/floodgate-velocity.jar $DOWNLOADS_USERNAME@$DOWNLOADS_SERVER_IP:~/uploads/$PROJECT/$GITHUB_RUN_NUMBER/
# Run the build script
rsync -P -e "ssh -o StrictHostKeyChecking=no -i id_ecdsa" metadata.json $DOWNLOADS_USERNAME@$DOWNLOADS_SERVER_IP:~/uploads/$PROJECT/$GITHUB_RUN_NUMBER/
- name: Notify Discord
if: ${{ (success() || failure()) && github.repository == 'GeyserMC/Floodgate' }}
uses: Tim203/actions-git-discord-webhook@main
# See https://github.com/Tim203/actions-git-discord-webhook/commits
uses: Tim203/actions-git-discord-webhook@70f38ded3aca51635ec978ab4e1a58cd4cd0c2ff
with:
webhook_url: ${{ secrets.DISCORD_WEBHOOK }}
39 changes: 28 additions & 11 deletions .github/workflows/pullrequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,55 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Set Build Number
run: |
echo "BUILD_NUMBER=${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV
- name: Checkout repository and submodules
uses: actions/checkout@v3
# See https://github.com/actions/checkout/commits
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
submodules: recursive

- name: Validate Gradle Wrapper
# See https://github.com/gradle/wrapper-validation-action/commits
uses: gradle/wrapper-validation-action@699bb18358f12c5b78b37bb0111d3a0e2276e0e2 # v2.1.1

- name: Set up JDK 17
uses: actions/setup-java@v2
# See https://github.com/actions/setup-java/commits
uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0
with:
distribution: 'temurin'
java-version: '17'
cache: 'gradle'
java-version: 17
distribution: temurin

- name: Build with Maven
run: ./gradlew build
- name: Build Floodgate
# See https://github.com/gradle/actions/commits
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0
with:
arguments: build
cache-read-only: true

- name: Archive artifacts (Floodgate Bungee)
uses: actions/upload-artifact@v2
# See https://github.com/actions/upload-artifact/commits
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
if: success()
with:
name: Floodgate Bungee
path: bungee/build/libs/floodgate-bungee.jar
if-no-files-found: error

- name: Archive artifacts (Floodgate Spigot)
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3
if: success()
with:
name: Floodgate Spigot
path: spigot/build/libs/floodgate-spigot.jar
if-no-files-found: error

- name: Archive artifacts (Floodgate Velocity)
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3
if: success()
with:
name: Floodgate Velocity
path: velocity/build/libs/floodgate-velocity.jar
path: velocity/build/libs/floodgate-velocity.jar
if-no-files-found: error
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "core/src/main/resources/languages"]
path = core/src/main/resources/languages
url = https://github.com/GeyserMC/languages
branch = l10n_floodgate
branch = floodgate
11 changes: 11 additions & 0 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

dependencies {
api("org.geysermc.geyser", "common", Versions.geyserVersion)
api("org.geysermc.cumulus", "cumulus", Versions.cumulusVersion)
api("org.geysermc.event", "events", Versions.eventsVersion)

compileOnly("io.netty", "netty-transport", Versions.nettyVersion)
}

tasks {
named<Jar>("jar") {
archiveClassifier.set("")
}
named<ShadowJar>("shadowJar") {
archiveClassifier.set("shaded")
}
}
1 change: 1 addition & 0 deletions build-logic/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name = "build-logic"
10 changes: 5 additions & 5 deletions build-logic/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@
*/

object Versions {
const val geyserVersion = "2.1.2-SNAPSHOT"
const val geyserVersion = "2.2.1-SNAPSHOT"
const val cumulusVersion = "1.1.2"
const val eventsVersion = "1.1-SNAPSHOT"
const val configUtilsVersion = "1.0-SNAPSHOT"
const val spigotVersion = "1.19.4-R0.1-SNAPSHOT"
const val fastutilVersion = "8.5.3"
const val guiceVersion = "5.1.0"
const val guiceVersion = "6.0.0"
const val nettyVersion = "4.1.49.Final"
const val snakeyamlVersion = "1.28"
const val cloudVersion = "1.5.0"
const val bstatsVersion = "d2fbbd6823"
const val cloudVersion = "2.0.0-beta.2"
const val bstatsVersion = "3.0.2"

const val javaWebsocketVersion = "1.5.2"

const val checkerQual = "3.19.0"
}
}
5 changes: 2 additions & 3 deletions build-logic/src/main/kotlin/extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ fun Project.versionWithBranchName(): String =
branchName().replace(Regex("[^0-9A-Za-z-_]"), "-") + '-' + version

fun buildNumber(): Int =
(System.getenv("GITHUB_RUN_NUMBER") ?: jenkinsBuildNumber())?.let { Integer.parseInt(it) } ?: -1
(System.getenv("BUILD_NUMBER"))?.let { Integer.parseInt(it) } ?: -1

fun buildNumberAsString(): String =
buildNumber().takeIf { it != -1 }?.toString() ?: "??"
Expand Down Expand Up @@ -81,5 +81,4 @@ private fun calcExclusion(section: String, bit: Int, excludedOn: Int): String =
if (excludedOn and bit > 0) section else ""

// todo remove these when we're not using Jenkins anymore
private fun jenkinsBranchName(): String? = System.getenv("BRANCH_NAME")
private fun jenkinsBuildNumber(): String? = System.getenv("BUILD_NUMBER")
private fun jenkinsBranchName(): String? = System.getenv("BRANCH_NAME")
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,10 @@ indra {

publishSnapshotsTo("geysermc", "https://repo.opencollab.dev/maven-snapshots")
publishReleasesTo("geysermc", "https://repo.opencollab.dev/maven-releases")
}

publishing {
// skip shadow jar from publishing. Workaround for https://github.com/johnrengelman/shadow/issues/651
val javaComponent = project.components["java"] as AdhocComponentWithVariants
javaComponent.withVariantsFromConfiguration(configurations["shadowRuntimeElements"]) { skip() }
}
8 changes: 4 additions & 4 deletions bungee/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
var bungeeCommit = "master-SNAPSHOT"
var bungeeVersion = "1.20-R0.3-SNAPSHOT"
var gsonVersion = "2.8.0"
var guavaVersion = "21.0"

dependencies {
api(projects.core)
implementation("cloud.commandframework", "cloud-bungee", Versions.cloudVersion)
implementation("org.incendo", "cloud-bungee", Versions.cloudVersion)
}

relocate("com.google.inject")
relocate("net.kyori")
relocate("cloud.commandframework")
relocate("org.incendo.cloud")
// used in cloud
relocate("io.leangen.geantyref")
// since 1.20
relocate("org.yaml")

// these dependencies are already present on the platform
provided("com.github.SpigotMC.BungeeCord", "bungeecord-proxy", bungeeCommit)
provided("net.md-5", "bungeecord-proxy", bungeeVersion)
provided("com.google.code.gson", "gson", gsonVersion)
provided("com.google.guava", "guava", guavaVersion)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,13 @@

package org.geysermc.floodgate.module;

import cloud.commandframework.CommandManager;
import cloud.commandframework.bungee.BungeeCommandManager;
import cloud.commandframework.execution.CommandExecutionCoordinator;
import com.google.inject.AbstractModule;
import com.google.inject.Provides;
import com.google.inject.Singleton;
import com.google.inject.name.Named;
import com.google.inject.name.Names;
import java.util.logging.Logger;
import lombok.RequiredArgsConstructor;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.api.plugin.Plugin;
import org.geysermc.floodgate.BungeePlugin;
Expand All @@ -51,6 +47,7 @@
import org.geysermc.floodgate.platform.util.PlatformUtils;
import org.geysermc.floodgate.player.FloodgateCommandPreprocessor;
import org.geysermc.floodgate.player.UserAudience;
import org.geysermc.floodgate.player.audience.FloodgateSenderMapper;
import org.geysermc.floodgate.pluginmessage.BungeePluginMessageRegistration;
import org.geysermc.floodgate.pluginmessage.BungeePluginMessageUtils;
import org.geysermc.floodgate.pluginmessage.BungeeSkinApplier;
Expand All @@ -60,6 +57,9 @@
import org.geysermc.floodgate.util.BungeeCommandUtil;
import org.geysermc.floodgate.util.BungeePlatformUtils;
import org.geysermc.floodgate.util.LanguageManager;
import org.incendo.cloud.CommandManager;
import org.incendo.cloud.bungee.BungeeCommandManager;
import org.incendo.cloud.execution.ExecutionCoordinator;

@RequiredArgsConstructor
public final class BungeePlatformModule extends AbstractModule {
Expand Down Expand Up @@ -88,9 +88,8 @@ public Plugin bungeePlugin() {
public CommandManager<UserAudience> commandManager(CommandUtil commandUtil) {
CommandManager<UserAudience> commandManager = new BungeeCommandManager<>(
plugin,
CommandExecutionCoordinator.simpleCoordinator(),
commandUtil::getUserAudience,
audience -> (CommandSender) audience.source()
ExecutionCoordinator.simpleCoordinator(),
new FloodgateSenderMapper<>(commandUtil)
);
commandManager.registerCommandPreProcessor(new FloodgateCommandPreprocessor<>(commandUtil));
return commandManager;
Expand Down
Loading

0 comments on commit eb04c7b

Please sign in to comment.