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.

318 lines
10KB

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