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.

299 lines
9.9KB

  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.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, &put_files/1, &copy_files/1, &copy_nginx_config/1]
  40. ]
  41. ]
  42. ]
  43. end
  44. def put_files(%{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: [:logger, :runtime_tools, :comeonin, :quack, :fast_sanitize, :ssl],
  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. {:tesla,
  121. git: "https://git.pleroma.social/pleroma/elixir-libraries/tesla.git",
  122. ref: "61b7503cef33f00834f78ddfafe0d5d9dec2270b",
  123. override: true},
  124. {:castore, "~> 0.1"},
  125. {:cowlib, "~> 2.8", override: true},
  126. {:gun,
  127. github: "ninenines/gun", ref: "e1a69b36b180a574c0ac314ced9613fdd52312cc", override: true},
  128. {:jason, "~> 1.0"},
  129. {:mogrify, "~> 0.6.1"},
  130. {:ex_aws, "~> 2.1"},
  131. {:ex_aws_s3, "~> 2.0"},
  132. {:sweet_xml, "~> 0.6.6"},
  133. {:earmark, "~> 1.3"},
  134. {:bbcode_pleroma, "~> 0.2.0"},
  135. {:ex_machina, "~> 2.3", only: :test},
  136. {:credo, "~> 1.1.0", only: [:dev, :test], runtime: false},
  137. {:mock, "~> 0.3.3", only: :test},
  138. {:crypt,
  139. git: "https://github.com/msantos/crypt", ref: "1f2b58927ab57e72910191a7ebaeff984382a1d3"},
  140. {:cors_plug, "~> 1.5"},
  141. {:ex_doc, "~> 0.21", only: :dev, runtime: false},
  142. {:web_push_encryption, "~> 0.2.1"},
  143. {:swoosh, "~> 0.23.2"},
  144. {:phoenix_swoosh, "~> 0.2"},
  145. {:gen_smtp, "~> 0.13"},
  146. {:websocket_client, git: "https://github.com/jeremyong/websocket_client.git", only: :test},
  147. {:ex_syslogger, "~> 1.4"},
  148. {:floki, "~> 0.25"},
  149. {:timex, "~> 3.5"},
  150. {:ueberauth, "~> 0.4"},
  151. {:auto_linker,
  152. git: "https://git.pleroma.social/pleroma/auto_linker.git",
  153. ref: "95e8188490e97505c56636c1379ffdf036c1fdde"},
  154. {:http_signatures,
  155. git: "https://git.pleroma.social/pleroma/http_signatures.git",
  156. ref: "293d77bb6f4a67ac8bde1428735c3b42f22cbb30"},
  157. {:telemetry, "~> 0.3"},
  158. {:poolboy, "~> 1.5"},
  159. {:prometheus_ex, "~> 3.0"},
  160. {:prometheus_plugs, "~> 1.1"},
  161. {:prometheus_phoenix, "~> 1.3"},
  162. {:prometheus_ecto, "~> 1.4"},
  163. {:recon, "~> 2.5"},
  164. {:quack, "~> 0.1.1"},
  165. {:joken, "~> 2.0"},
  166. {:benchee, "~> 1.0"},
  167. {:esshd, "~> 0.1.0", runtime: Application.get_env(:esshd, :enabled, false)},
  168. {:ex_const, "~> 0.2"},
  169. {:plug_static_index_html, "~> 1.0.0"},
  170. {:excoveralls, "~> 0.12.1", only: :test},
  171. {:flake_id, "~> 0.1.0"},
  172. {:remote_ip,
  173. git: "https://git.pleroma.social/pleroma/remote_ip.git",
  174. ref: "825dc00aaba5a1b7c4202a532b696b595dd3bcb3"},
  175. {:captcha,
  176. git: "https://git.pleroma.social/pleroma/elixir-libraries/elixir-captcha.git",
  177. ref: "e0f16822d578866e186a0974d65ad58cddc1e2ab"},
  178. {:mox, "~> 0.5", only: :test},
  179. {:restarter, path: "./restarter"},
  180. {:open_api_spex, "~> 3.6"}
  181. ] ++ oauth_deps()
  182. end
  183. # Aliases are shortcuts or tasks specific to the current project.
  184. # For example, to create, migrate and run the seeds file at once:
  185. #
  186. # $ mix ecto.setup
  187. #
  188. # See the documentation for `Mix` for more info on aliases.
  189. defp aliases do
  190. [
  191. "ecto.migrate": ["pleroma.ecto.migrate"],
  192. "ecto.rollback": ["pleroma.ecto.rollback"],
  193. "ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"],
  194. "ecto.reset": ["ecto.drop", "ecto.setup"],
  195. test: ["ecto.create --quiet", "ecto.migrate", "test"],
  196. docs: ["pleroma.docs", "docs"]
  197. ]
  198. end
  199. # Builds a version string made of:
  200. # * the application version
  201. # * a pre-release if ahead of the tag: the describe string (-count-commithash)
  202. # * branch name
  203. # * build metadata:
  204. # * a build name if `PLEROMA_BUILD_NAME` or `:pleroma, :build_name` is defined
  205. # * the mix environment if different than prod
  206. defp version(version) do
  207. identifier_filter = ~r/[^0-9a-z\-]+/i
  208. # Pre-release version, denoted from patch version with a hyphen
  209. git_pre_release =
  210. with {tag, 0} <-
  211. System.cmd("git", ["describe", "--tags", "--abbrev=0"], stderr_to_stdout: true),
  212. {describe, 0} <- System.cmd("git", ["describe", "--tags", "--abbrev=8"]) do
  213. describe
  214. |> String.trim()
  215. |> String.replace(String.trim(tag), "")
  216. |> String.trim_leading("-")
  217. |> String.trim()
  218. else
  219. _ ->
  220. {commit_hash, 0} = System.cmd("git", ["rev-parse", "--short", "HEAD"])
  221. "0-g" <> String.trim(commit_hash)
  222. end
  223. # Branch name as pre-release version component, denoted with a dot
  224. branch_name =
  225. with {branch_name, 0} <- System.cmd("git", ["rev-parse", "--abbrev-ref", "HEAD"]),
  226. branch_name <- String.trim(branch_name),
  227. branch_name <- System.get_env("PLEROMA_BUILD_BRANCH") || branch_name,
  228. true <-
  229. !Enum.any?(["master", "HEAD", "release/", "stable"], fn name ->
  230. String.starts_with?(name, branch_name)
  231. end) do
  232. branch_name =
  233. branch_name
  234. |> String.trim()
  235. |> String.replace(identifier_filter, "-")
  236. branch_name
  237. end
  238. build_name =
  239. cond do
  240. name = Application.get_env(:pleroma, :build_name) -> name
  241. name = System.get_env("PLEROMA_BUILD_NAME") -> name
  242. true -> nil
  243. end
  244. env_name = if Mix.env() != :prod, do: to_string(Mix.env())
  245. env_override = System.get_env("PLEROMA_BUILD_ENV")
  246. env_name =
  247. case env_override do
  248. nil -> env_name
  249. env_override when env_override in ["", "prod"] -> nil
  250. env_override -> env_override
  251. end
  252. # Pre-release version, denoted by appending a hyphen
  253. # and a series of dot separated identifiers
  254. pre_release =
  255. [git_pre_release, branch_name]
  256. |> Enum.filter(fn string -> string && string != "" end)
  257. |> Enum.join(".")
  258. |> (fn
  259. "" -> nil
  260. string -> "-" <> String.replace(string, identifier_filter, "-")
  261. end).()
  262. # Build metadata, denoted with a plus sign
  263. build_metadata =
  264. [build_name, env_name]
  265. |> Enum.filter(fn string -> string && string != "" end)
  266. |> Enum.join(".")
  267. |> (fn
  268. "" -> nil
  269. string -> "+" <> String.replace(string, identifier_filter, "-")
  270. end).()
  271. [version, pre_release, build_metadata]
  272. |> Enum.filter(fn string -> string && string != "" end)
  273. |> Enum.join()
  274. end
  275. end