| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- defmodule Vaccins.MixProject do
- use Mix.Project
- def project do
- [
- app: :vaccins,
- version: from_file(),
- elixir: "~> 1.7",
- elixirc_paths: elixirc_paths(Mix.env()),
- compilers: [:phoenix, :gettext] ++ Mix.compilers(),
- start_permanent: Mix.env() == :prod,
- aliases: aliases(),
- deps: deps(),
- releases: [vaccins: [steps: [:assemble, &export_sha1/1, &export_docker_image_tag/1, :tar]]]
- ]
- end
- # Configuration for the OTP application.
- #
- # Type `mix help compile.app` for more information.
- def application do
- [
- mod: {Vaccins.Application, []},
- extra_applications: [:logger, :runtime_tools]
- ]
- end
- # Specifies which paths to compile per environment.
- defp elixirc_paths(:test), do: ["config", "lib", "test/support"]
- defp elixirc_paths(_), do: ["config", "lib"]
- # Specifies your project dependencies.
- #
- # Type `mix help deps` for examples and options.
- defp deps do
- [
- {:phoenix, "> 1.5.3"},
- {:phoenix_live_view, "> 0.13.0"},
- {:phoenix_html, "> 2.11.0"},
- {:phoenix_live_reload, "> 1.2.0", only: :dev},
- {:phoenix_live_dashboard, "> 0.2.0"},
- {:telemetry_metrics, "> 0.4.0"},
- {:telemetry_poller, "> 0.4.0"},
- {:gettext, "> 0.11.0"},
- {:jason, "> 1.0.0"},
- {:plug_cowboy, "> 2.0.0"},
- {:floki, "~> 0.30.0"},
- {:finch, "~> 0.6"},
- {:ex2ms, "~> 1.0"},
- {:ecto, "~> 3.6"},
- {:phoenix_ecto, "~> 4.1"},
- {:tzdata, "~> 1.1"}
- ]
- end
- # Aliases are shortcuts or tasks specific to the current project.
- # For example, to install project dependencies and perform other setup tasks, run:
- #
- # $ mix setup
- #
- # See the documentation for `Mix` for more info on aliases.
- defp aliases do
- [
- setup: ["deps.get", "cmd npm install --prefix assets"],
- deploy: [
- "cmd npm --prefix ./assets ci --progress=false --no-audit --loglevel=error",
- "cmd npm run --prefix ./assets deploy",
- "phx.digest",
- "release"
- ]
- ]
- end
- defp from_file(file \\ "VERSION") do
- with {:ok, described} <- File.read(file),
- {:ok, version} <- described |> String.trim() |> to_semver_string() do
- version
- end
- end
- defp to_semver_string(described) when is_binary(described) do
- with {:ok, _} <- described |> Version.parse(), do: {:ok, described}
- end
- defp export_sha1(rel) when is_struct(rel, Mix.Release) do
- with {sha1, 0} <- System.cmd("git", ["rev-parse", "HEAD"]),
- :ok <- rel |> write_in_rel_path("git-sha1", sha1),
- do: rel
- end
- defp export_docker_image_tag(rel) when is_struct(rel, Mix.Release) do
- with image_tag when not is_nil(image_tag) <- System.get_env("DOCKER_IMAGE_TAG"),
- :ok <- rel |> write_in_rel_path("docker-image-tag", image_tag) do
- rel
- else
- nil -> rel
- end
- end
- defp write_in_rel_path(%{version_path: path}, file_path, content) do
- path |> Path.join(file_path) |> File.write(content)
- end
- end
|