Fork of Pleroma with site-specific changes and feature branches https://git.pleroma.social/pleroma/pleroma
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

297 line
9.6KB

  1. defmodule Pleroma.Mixfile do
  2. use Mix.Project
  3. def project do
  4. [
  5. app: :pleroma,
  6. version: version("2.0.7"),
  7. elixir: "~> 1.8",
  8. elixirc_paths: elixirc_paths(Mix.env()),
  9. compilers: [:phoenix, :gettext] ++ Mix.compilers(),
  10. elixirc_options: [warnings_as_errors: warnings_as_errors(Mix.env())],
  11. xref: [exclude: [:eldap]],
  12. start_permanent: Mix.env() == :prod,
  13. aliases: aliases(),
  14. deps: deps(),
  15. test_coverage: [tool: ExCoveralls],
  16. preferred_cli_env: ["coveralls.html": :test],
  17. # Docs
  18. name: "Pleroma",
  19. homepage_url: "https://pleroma.social/",
  20. source_url: "https://git.pleroma.social/pleroma/pleroma",
  21. docs: [
  22. source_url_pattern:
  23. "https://git.pleroma.social/pleroma/pleroma/blob/develop/%{path}#L%{line}",
  24. logo: "priv/static/static/logo.png",
  25. extras: ["README.md", "CHANGELOG.md"] ++ Path.wildcard("docs/**/*.md"),
  26. groups_for_extras: [
  27. "Installation manuals": Path.wildcard("docs/installation/*.md"),
  28. Configuration: Path.wildcard("docs/config/*.md"),
  29. Administration: Path.wildcard("docs/admin/*.md"),
  30. "Pleroma's APIs and Mastodon API extensions": Path.wildcard("docs/api/*.md")
  31. ],
  32. main: "readme",
  33. output: "priv/static/doc"
  34. ],
  35. releases: [
  36. pleroma: [
  37. include_executables_for: [:unix],
  38. applications: [ex_syslogger: :load, syslog: :load, eldap: :transient],
  39. steps: [:assemble, &copy_files/1, &copy_nginx_config/1]
  40. ]
  41. ]
  42. ]
  43. end
  44. def copy_files(%{path: target_path} = release) do
  45. File.cp_r!("./rel/files", target_path)
  46. release
  47. end
  48. def copy_nginx_config(%{path: target_path} = release) do
  49. File.cp!(
  50. "./installation/pleroma.nginx",
  51. Path.join([target_path, "installation", "pleroma.nginx"])
  52. )
  53. release
  54. end
  55. # Configuration for the OTP application.
  56. #
  57. # Type `mix help compile.app` for more information.
  58. def application do
  59. [
  60. mod: {Pleroma.Application, []},
  61. extra_applications: [
  62. :logger,
  63. :runtime_tools,
  64. :comeonin,
  65. :quack,
  66. :fast_sanitize,
  67. :ssl
  68. ],
  69. included_applications: [:ex_syslogger]
  70. ]
  71. end
  72. # Specifies which paths to compile per environment.
  73. defp elixirc_paths(:benchmark), do: ["lib", "benchmarks"]
  74. defp elixirc_paths(:test), do: ["lib", "test/support"]
  75. defp elixirc_paths(_), do: ["lib"]
  76. defp warnings_as_errors(:prod), do: false
  77. # Uncomment this if you need testing configurable_from_database logic
  78. # defp warnings_as_errors(:dev), do: false
  79. defp warnings_as_errors(_), do: true
  80. # Specifies OAuth dependencies.
  81. defp oauth_deps do
  82. oauth_strategy_packages =
  83. System.get_env("OAUTH_CONSUMER_STRATEGIES")
  84. |> to_string()
  85. |> String.split()
  86. |> Enum.map(fn strategy_entry ->
  87. with [_strategy, dependency] <- String.split(strategy_entry, ":") do
  88. dependency
  89. else
  90. [strategy] -> "ueberauth_#{strategy}"
  91. end
  92. end)
  93. for s <- oauth_strategy_packages, do: {String.to_atom(s), ">= 0.0.0"}
  94. end
  95. # Specifies your project dependencies.
  96. #
  97. # Type `mix help deps` for examples and options.
  98. defp deps do
  99. [
  100. {:phoenix, "~> 1.4.8"},
  101. {:tzdata, "~> 0.5.21"},
  102. {:plug_cowboy, "~> 2.0"},
  103. {:phoenix_pubsub, "~> 1.1"},
  104. {:phoenix_ecto, "~> 4.0"},
  105. {:ecto_enum, "~> 1.4"},
  106. {:ecto_sql, "~> 3.3.2"},
  107. {:postgrex, ">= 0.13.5"},
  108. {:oban, "~> 0.12.1"},
  109. {:gettext, "~> 0.15"},
  110. {:comeonin, "~> 4.1.1"},
  111. {:pbkdf2_elixir, "~> 0.12.3"},
  112. {:trailing_format_plug, "~> 0.0.7"},
  113. {:fast_sanitize, "~> 0.1"},
  114. {:html_entities, "~> 0.5", override: true},
  115. {:phoenix_html, "~> 2.10"},
  116. {:calendar, "~> 0.17.4"},
  117. {:cachex, "~> 3.2"},
  118. {:poison, "~> 3.0", override: true},
  119. {:tesla, "~> 1.3", override: true},
  120. {:jason, "~> 1.0"},
  121. {:mogrify, "~> 0.6.1"},
  122. {:ex_aws, "~> 2.1"},
  123. {:ex_aws_s3, "~> 2.0"},
  124. {:sweet_xml, "~> 0.6.6"},
  125. {:earmark, "~> 1.3"},
  126. {:bbcode_pleroma, "~> 0.2.0"},
  127. {:ex_machina, "~> 2.3", only: :test},
  128. {:credo, "~> 1.1.0", only: [:dev, :test], runtime: false},
  129. {:mock, "~> 0.3.3", only: :test},
  130. {:crypt,
  131. git: "https://github.com/msantos/crypt", ref: "f63a705f92c26955977ee62a313012e309a4d77a"},
  132. {:cors_plug, "~> 1.5"},
  133. {:ex_doc, "~> 0.21", only: :dev, runtime: false},
  134. {:web_push_encryption, "~> 0.2.1"},
  135. {:swoosh, "~> 0.23.2"},
  136. {:phoenix_swoosh, "~> 0.2"},
  137. {:gen_smtp, "~> 0.13"},
  138. {:websocket_client, git: "https://github.com/jeremyong/websocket_client.git", only: :test},
  139. {:ex_syslogger, "~> 1.4"},
  140. {:floki, "~> 0.25"},
  141. {:timex, "~> 3.5"},
  142. {:ueberauth, "~> 0.4"},
  143. {:auto_linker,
  144. git: "https://git.pleroma.social/pleroma/auto_linker.git",
  145. ref: "95e8188490e97505c56636c1379ffdf036c1fdde"},
  146. {:http_signatures,
  147. git: "https://git.pleroma.social/pleroma/http_signatures.git",
  148. ref: "293d77bb6f4a67ac8bde1428735c3b42f22cbb30"},
  149. {:telemetry, "~> 0.3"},
  150. {:poolboy, "~> 1.5"},
  151. {:prometheus_ex, "~> 3.0"},
  152. {:prometheus_plugs, "~> 1.1"},
  153. {:prometheus_phoenix, "~> 1.3"},
  154. {:prometheus_ecto, "~> 1.4"},
  155. {:recon, "~> 2.5"},
  156. {:quack, "~> 0.1.1"},
  157. {:joken, "~> 2.0"},
  158. {:benchee, "~> 1.0"},
  159. {:esshd, "~> 0.1.0", runtime: Application.get_env(:esshd, :enabled, false)},
  160. {:ex_const, "~> 0.2"},
  161. {:plug_static_index_html, "~> 1.0.0"},
  162. {:excoveralls, "~> 0.12.1", only: :test},
  163. {:flake_id, "~> 0.1.0"},
  164. {:remote_ip,
  165. git: "https://git.pleroma.social/pleroma/remote_ip.git",
  166. ref: "825dc00aaba5a1b7c4202a532b696b595dd3bcb3"},
  167. {:captcha,
  168. git: "https://git.pleroma.social/pleroma/elixir-libraries/elixir-captcha.git",
  169. ref: "e0f16822d578866e186a0974d65ad58cddc1e2ab"},
  170. {:mox, "~> 0.5", only: :test},
  171. {:restarter, path: "./restarter"}
  172. ] ++ oauth_deps()
  173. end
  174. # Aliases are shortcuts or tasks specific to the current project.
  175. # For example, to create, migrate and run the seeds file at once:
  176. #
  177. # $ mix ecto.setup
  178. #
  179. # See the documentation for `Mix` for more info on aliases.
  180. defp aliases do
  181. [
  182. "ecto.migrate": ["pleroma.ecto.migrate"],
  183. "ecto.rollback": ["pleroma.ecto.rollback"],
  184. "ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"],
  185. "ecto.reset": ["ecto.drop", "ecto.setup"],
  186. test: ["ecto.create --quiet", "ecto.migrate", "test"],
  187. docs: ["pleroma.docs", "docs"]
  188. ]
  189. end
  190. # Builds a version string made of:
  191. # * the application version
  192. # * a pre-release if ahead of the tag: the describe string (-count-commithash)
  193. # * branch name
  194. # * build metadata:
  195. # * a build name if `PLEROMA_BUILD_NAME` or `:pleroma, :build_name` is defined
  196. # * the mix environment if different than prod
  197. defp version(version) do
  198. identifier_filter = ~r/[^0-9a-z\-]+/i
  199. # Pre-release version, denoted from patch version with a hyphen
  200. {tag, tag_err} =
  201. System.cmd("git", ["describe", "--tags", "--abbrev=0"], stderr_to_stdout: true)
  202. {describe, describe_err} = System.cmd("git", ["describe", "--tags", "--abbrev=8"])
  203. {commit_hash, commit_hash_err} = System.cmd("git", ["rev-parse", "--short", "HEAD"])
  204. git_pre_release =
  205. cond do
  206. tag_err == 0 and describe_err == 0 ->
  207. describe
  208. |> String.trim()
  209. |> String.replace(String.trim(tag), "")
  210. |> String.trim_leading("-")
  211. |> String.trim()
  212. commit_hash_err == 0 ->
  213. "0-g" <> String.trim(commit_hash)
  214. true ->
  215. ""
  216. end
  217. # Branch name as pre-release version component, denoted with a dot
  218. branch_name =
  219. with {branch_name, 0} <- System.cmd("git", ["rev-parse", "--abbrev-ref", "HEAD"]),
  220. branch_name <- String.trim(branch_name),
  221. branch_name <- System.get_env("PLEROMA_BUILD_BRANCH") || branch_name,
  222. true <-
  223. !Enum.any?(["master", "HEAD", "release/", "stable"], fn name ->
  224. String.starts_with?(name, branch_name)
  225. end) do
  226. branch_name =
  227. branch_name
  228. |> String.trim()
  229. |> String.replace(identifier_filter, "-")
  230. branch_name
  231. else
  232. _ -> "stable"
  233. end
  234. build_name =
  235. cond do
  236. name = Application.get_env(:pleroma, :build_name) -> name
  237. name = System.get_env("PLEROMA_BUILD_NAME") -> name
  238. true -> nil
  239. end
  240. env_name = if Mix.env() != :prod, do: to_string(Mix.env())
  241. env_override = System.get_env("PLEROMA_BUILD_ENV")
  242. env_name =
  243. case env_override do
  244. nil -> env_name
  245. env_override when env_override in ["", "prod"] -> nil
  246. env_override -> env_override
  247. end
  248. # Pre-release version, denoted by appending a hyphen
  249. # and a series of dot separated identifiers
  250. pre_release =
  251. [git_pre_release, branch_name]
  252. |> Enum.filter(fn string -> string && string != "" end)
  253. |> Enum.join(".")
  254. |> (fn
  255. "" -> nil
  256. string -> "-" <> String.replace(string, identifier_filter, "-")
  257. end).()
  258. # Build metadata, denoted with a plus sign
  259. build_metadata =
  260. [build_name, env_name]
  261. |> Enum.filter(fn string -> string && string != "" end)
  262. |> Enum.join(".")
  263. |> (fn
  264. "" -> nil
  265. string -> "+" <> String.replace(string, identifier_filter, "-")
  266. end).()
  267. [version, pre_release, build_metadata]
  268. |> Enum.filter(fn string -> string && string != "" end)
  269. |> Enum.join()
  270. end
  271. end