diff --git a/.github/hooks/pre-push b/.github/hooks/pre-push new file mode 100755 index 0000000..661e72b --- /dev/null +++ b/.github/hooks/pre-push @@ -0,0 +1,7 @@ +#!/bin/sh + +elixir scripts/validate_version.exs + +if [ $? -ne 0 ]; then + exit 1 +fi diff --git a/CHANGES.txt b/CHANGES.txt index fb909ee..c4a33fd 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,6 @@ +0.2.1 (February 24, 2025): + - Fixed the SDK language version to correctly reflect the package version when it's installed from hex.pm. + 0.2.0 (February 14, 2025): - Added new variations of the get treatment functions to support evaluating flags in given flag set/s: `Split.get_treatments_by_flag_set/3`, `Split.get_treatments_by_flag_sets/3`, `Split.get_treatments_with_config_by_flag_set/3`, and `Split.get_treatments_with_config_by_flag_sets/3`. - Updated the `:socket_path` option for `Split.Supervisor.start_link/1` to be optional, defaulting to `"/var/run/splitd.sock"`. diff --git a/lib/split/rpc/message.ex b/lib/split/rpc/message.ex index 3a74147..4dbd5cc 100644 --- a/lib/split/rpc/message.ex +++ b/lib/split/rpc/message.ex @@ -5,7 +5,7 @@ defmodule Split.RPC.Message do use Split.RPC.Opcodes @protocol_version 0x01 - @client_id "Splitd_Elixir-" <> to_string(Application.spec(:split, :vsn)) + @client_id "Splitd_Elixir-0.2.1-rc.0" @type opcode :: unquote(Enum.reduce(@opcodes, &{:|, [], [&1, &2]})) @type protocol_version :: unquote(@protocol_version) @@ -37,7 +37,7 @@ defmodule Split.RPC.Message do ## Examples iex> Message.register() - %Message{v: 1, o: 0, a: ["123", "Splitd_Elixir-", 1]} + %Message{v: 1, o: 0, a: ["123", "Splitd_Elixir-0.2.1-rc.0", 1]} """ @spec register() :: t() def register, do: %__MODULE__{o: @register_opcode, a: ["123", @client_id, 1]} diff --git a/mix.exs b/mix.exs index 2caeccf..409c057 100644 --- a/mix.exs +++ b/mix.exs @@ -4,7 +4,7 @@ defmodule SplitThinElixir.MixProject do def project do [ app: :split, - version: "0.2.0", + version: "0.2.1-rc.0", elixir: "~> 1.14", elixirc_paths: elixirc_paths(Mix.env()), start_permanent: Mix.env() == :prod, diff --git a/scripts/validate_version.exs b/scripts/validate_version.exs new file mode 100644 index 0000000..fe9cfe0 --- /dev/null +++ b/scripts/validate_version.exs @@ -0,0 +1,22 @@ +#!/usr/bin/env elixir + +# Read mix.exs version +{:ok, mix_content} = File.read("mix.exs") +version = Regex.run(~r/version: "([^"]+)"/, mix_content) +|> Enum.at(1) + +# Read message.ex @client_id +{:ok, message_content} = File.read("lib/split/rpc/message.ex") +client_id_version = Regex.run(~r/@client_id "Splitd_Elixir-([^"]+)"/, message_content) +|> Enum.at(1) + +if version != client_id_version do + IO.puts :stderr, """ + Error: Version mismatch! + mix.exs version: #{version} + message.ex @client_id version: #{client_id_version} + + Please update the @client_id in lib/split/rpc/message.ex to match the version in mix.exs + """ + System.halt(1) +end