diff --git a/.gitignore b/.gitignore index 08463a7ca..8cdb87b5d 100644 --- a/.gitignore +++ b/.gitignore @@ -28,7 +28,6 @@ ae_mdw-*.tar .DS_Store .elixir_ls/ log/ -AEMDW_REVISION REVISION VERSION *~ diff --git a/Dockerfile b/Dockerfile index b38a54a43..b47afbe06 100644 --- a/Dockerfile +++ b/Dockerfile @@ -34,7 +34,6 @@ COPY ./docker/aeternity.yaml /home/aeternity/aeternity.yaml # Set build git revision RUN mkdir /home/aeternity/node/ae_mdw COPY .git .git -RUN BUILD_REV="$(git log -1 --format=%h)" && echo $BUILD_REV > /home/aeternity/node/ae_mdw/AEMDW_REVISION WORKDIR /home/aeternity/node diff --git a/config/prod.exs b/config/prod.exs index 71e372e0d..fa488214e 100644 --- a/config/prod.exs +++ b/config/prod.exs @@ -1,6 +1,8 @@ import Config -config :ae_mdw, build_revision: String.trim(File.read!("AEMDW_REVISION")) +# Stat +{revision, 0} = System.cmd("git", ["log", "-1", "--format=%h"]) +config :ae_mdw, build_revision: String.trim(revision) # Logging config :logger, diff --git a/mix.exs b/mix.exs index 63048b5a3..d983ea62d 100644 --- a/mix.exs +++ b/mix.exs @@ -1,10 +1,12 @@ defmodule AeMdw.MixProject do use Mix.Project + @version "1.48.1" + def project() do [ app: :ae_mdw, - version: "1.48.1", + version: @version, elixir: "~> 1.10", elixirc_paths: elixirc_paths(Mix.env()), elixirc_options: [ @@ -109,6 +111,20 @@ defmodule AeMdw.MixProject do coveralls: :test, "test.integration": :test, "test.iteration": :test + ], + releases: [ + ae_mdw: fn -> + if is_nil(System.get_env("INCLUDE_LOCAL_NODE")) do + [] + else + [ + steps: [&build_node/1, ©_node/1, :assemble, :tar, &remove_node/1], + overlays: ["node-tmp"], + version: "v" <> @version <> "-" <> to_string(:erlang.system_info(:system_architecture)) + ] + end + + end ] ] end @@ -184,4 +200,47 @@ defmodule AeMdw.MixProject do ] ] end + + defp build_node(release) do + node_path = node_build_root() + IO.inspect(node_path, label: "Building node in directory") + {_, 0} = System.cmd("make", ["prod-package"], cd: node_path) + release + end + + defp copy_node(release) do + tar_file = node_tar_file() + File.rm_rf("node-tmp") + File.mkdir_p("node-tmp/local/rel/aeternity/data/mnesia") + IO.inspect(tar_file, label: "Using aeternity release") + :erl_tar.extract(tar_file, [:compressed, {:cwd, "node-tmp/local/rel/aeternity"}]) + release + end + + defp remove_node(release) do + File.rm_rf("node-tmp") + release + end + + defp node_build_root() do + System.get_env("NODE_BUILD_ROOT", "../aeternity/") + end + + defp node_tar_file() do + reldir = Path.join(node_build_root(), "_build/prod/rel/aeternity") + files = File.ls!(reldir) + tar_file = latest_tar_file(files, reldir) + Path.join(reldir, tar_file) + end + + defp latest_tar_file(files, reldir) do + files + |> Enum.filter(fn file -> String.ends_with?(file, ".tar.gz") end) + |> Enum.filter(fn file -> String.starts_with?(file, "aeternity") end) + |> Enum.map(fn file -> {file, File.lstat!(Path.join(reldir, file))} end) + |> Enum.sort(fn {_, f1}, {_, f2} -> f1.ctime > f2.ctime end) + |> Enum.map(fn {file, _} -> file end) + |> List.first() + end + end diff --git a/mix.lock b/mix.lock index 36bef6fcc..5c9425bd7 100644 --- a/mix.lock +++ b/mix.lock @@ -1,5 +1,5 @@ %{ - "ae_plugin": {:git, "https://github.com/aeternity/ae_plugin.git", "f5438d957d871f6a32b10a2be8f6e7c4d3550534", []}, + "ae_plugin": {:git, "https://github.com/aeternity/ae_plugin.git", "49c6541dbd6c82f0ce00718c288077823661986f", []}, "benchee": {:hex, :benchee, "1.0.1", "66b211f9bfd84bd97e6d1beaddf8fc2312aaabe192f776e8931cb0c16f53a521", [:mix], [{:deep_merge, "~> 1.0", [hex: :deep_merge, repo: "hexpm", optional: false]}], "hexpm", "3ad58ae787e9c7c94dd7ceda3b587ec2c64604563e049b2a0e8baafae832addb"}, "blankable": {:hex, :blankable, "1.0.0", "89ab564a63c55af117e115144e3b3b57eb53ad43ba0f15553357eb283e0ed425", [:mix], [], "hexpm", "7cf11aac0e44f4eedbee0c15c1d37d94c090cb72a8d9fddf9f7aec30f9278899"}, "bunt": {:hex, :bunt, "0.2.1", "e2d4792f7bc0ced7583ab54922808919518d0e57ee162901a16a1b6664ef3b14", [:mix], [], "hexpm", "a330bfb4245239787b15005e66ae6845c9cd524a288f0d141c148b02603777a5"},