Update release system
All checks were successful
Build & Test / nix-build (push) Successful in 1m45s

This commit is contained in:
Kodi Craft 2024-10-07 13:52:33 +02:00
parent 2ef24bbe51
commit 5743ae55e0
Signed by: kodi
GPG Key ID: 69D9EED60B242822
5 changed files with 19 additions and 10 deletions

View File

@ -245,10 +245,10 @@ defmodule Amethyst.ConnectionHandler do
end end
rescue rescue
e -> e ->
if Mix.env() == :dev do if Application.get_env(:amethyst, :release, false) do
send(self(), {:disconnect, "§cError handling packet #{inspect(id, base: :hex)}:\n#{Exception.format(:error, e, __STACKTRACE__)}"})
Logger.error("Error handling packet with ID #{inspect(id, base: :hex)} in state #{connstate}: #{Exception.format(:error, e, __STACKTRACE__)}") Logger.error("Error handling packet with ID #{inspect(id, base: :hex)} in state #{connstate}: #{Exception.format(:error, e, __STACKTRACE__)}")
else else
send(self(), {:disconnect, "§cError handling packet #{inspect(id, base: :hex)}:\n#{Exception.format(:error, e, __STACKTRACE__)}"})
Logger.error("Error handling packet with ID #{inspect(id, base: :hex)} in state #{connstate}: #{Exception.format(:error, e, __STACKTRACE__)}") Logger.error("Error handling packet with ID #{inspect(id, base: :hex)} in state #{connstate}: #{Exception.format(:error, e, __STACKTRACE__)}")
end end
state state

View File

@ -28,7 +28,8 @@ defmodule Amethyst.ConnectionState.Macros do
defmacro defpacket_clientbound(name, id, version, signature, where \\ true) do defmacro defpacket_clientbound(name, id, version, signature, where \\ true) do
quote do quote do
def serialize(%{packet_type: unquote(name)} = packet, unquote(version)) when unquote(where) do def serialize(%{packet_type: unquote(name)} = packet, unquote(version)) when unquote(where) do
if Amethyst.ConnectionState.Macros.check_type(packet, unquote(signature)) do # Don't check types if we are in release mode
if Application.get_env(:amethyst, :release, false) || Amethyst.ConnectionState.Macros.check_type(packet, unquote(signature)) do
Amethyst.Minecraft.Write.varint(unquote(id)) <> Amethyst.ConnectionState.Macros.write_signature(packet, unquote(signature)) Amethyst.Minecraft.Write.varint(unquote(id)) <> Amethyst.ConnectionState.Macros.write_signature(packet, unquote(signature))
else else
raise "Invalid packet type for #{unquote(name)}! Got #{inspect(packet)}" raise "Invalid packet type for #{unquote(name)}! Got #{inspect(packet)}"

View File

@ -6,4 +6,5 @@ config :amethyst,
auth: true, # Whether or not users should be authenticated with Mojang. auth: true, # Whether or not users should be authenticated with Mojang.
session_server: "https://sessionserver.mojang.com", # Base URL to the Mojang session server session_server: "https://sessionserver.mojang.com", # Base URL to the Mojang session server
compression: 256, # Packets larger than this amount are sent compressed. Set to nil to disable compression. compression: 256, # Packets larger than this amount are sent compressed. Set to nil to disable compression.
default_game: Example.Game # Which game new players should be sent to default_game: Example.Game, # Which game new players should be sent to
release: config_env() == :prod # If this is set to false, Amethyst will perform additional checks at runtime and will handle errors more loosely

View File

@ -43,14 +43,20 @@
}) })
); );
#secrets = import ./secrets.nix; package = env: release: pkgs: (pkgs.beamPackages.mixRelease {
package = env: pkgs: (pkgs.beamPackages.mixRelease {
pname = "amethyst"; pname = "amethyst";
version = "0.1.0"; version = "0.1.0";
src = ./.; src = ./.;
elixir = pkgs.elixir; elixir = pkgs.elixir;
mixEnv = env; mixEnv = env;
mixReleaseName = release;
# This should just be part of mixRelease, I don't know why we need to do it here
installPhase = ''
runHook preInstall
mix release ${release} --no-deps-check --path "$out"
runHook postInstall
'';
meta.mainProgram = "${release}";
erlangDeterministicBuilds = false; # Technically less pure but allows doctests erlangDeterministicBuilds = false; # Technically less pure but allows doctests
removeCookie = false; # Insecure; Access to the file system can allow the cookie to be read and provides remote control of the Erlang VM removeCookie = false; # Insecure; Access to the file system can allow the cookie to be read and provides remote control of the Erlang VM
mixNixDeps = import ./mix.nix {inherit lib; beamPackages = pkgs.beamPackages;}; mixNixDeps = import ./mix.nix {inherit lib; beamPackages = pkgs.beamPackages;};
@ -64,8 +70,9 @@
in { in {
packages = eachSystem (pkgs: packages = eachSystem (pkgs:
{ {
default = package "prod" pkgs; default = package "prod" "amethyst" pkgs;
dev = package "dev" pkgs; dev = package "dev" "amethyst" pkgs;
example = package "prop" "example" pkgs;
} }
); );

View File

@ -8,7 +8,7 @@ defmodule AmethystUmbrella.MixProject do
elixir: "~> 1.17", elixir: "~> 1.17",
start_permanent: Mix.env() == :prod, start_permanent: Mix.env() == :prod,
deps: deps(), deps: deps(),
default_release: :amethyst, # default_release: :amethyst,
releases: [ releases: [
amethyst: [ amethyst: [