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.

289 lines
9.7KB

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