Fork of Pleroma with site-specific changes and feature branches https://git.pleroma.social/pleroma/pleroma
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

326 satır
11KB

  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, "~> 1.0.3"},
  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,
  151. git: "https://github.com/swoosh/swoosh",
  152. ref: "c96e0ca8a00d8f211ec1f042a4626b09f249caa5",
  153. override: true},
  154. {:phoenix_swoosh, "~> 0.2"},
  155. {:gen_smtp, "~> 0.13"},
  156. {:websocket_client, git: "https://github.com/jeremyong/websocket_client.git", only: :test},
  157. {:ex_syslogger, "~> 1.4"},
  158. {:floki, "~> 0.25"},
  159. {:timex, "~> 3.5"},
  160. {:ueberauth, "~> 0.4"},
  161. {:auto_linker,
  162. git: "https://git.pleroma.social/pleroma/auto_linker.git",
  163. ref: "95e8188490e97505c56636c1379ffdf036c1fdde"},
  164. {:http_signatures,
  165. git: "https://git.pleroma.social/pleroma/http_signatures.git",
  166. ref: "293d77bb6f4a67ac8bde1428735c3b42f22cbb30"},
  167. {:telemetry, "~> 0.3"},
  168. {:poolboy, "~> 1.5"},
  169. {:prometheus_ex, "~> 3.0"},
  170. {:prometheus_plugs, "~> 1.1"},
  171. {:prometheus_phoenix, "~> 1.3"},
  172. {:prometheus_ecto, "~> 1.4"},
  173. {:recon, "~> 2.5"},
  174. {:quack, "~> 0.1.1"},
  175. {:joken, "~> 2.0"},
  176. {:benchee, "~> 1.0"},
  177. {:pot, "~> 0.10.2"},
  178. {:esshd, "~> 0.1.0", runtime: Application.get_env(:esshd, :enabled, false)},
  179. {:ex_const, "~> 0.2"},
  180. {:plug_static_index_html, "~> 1.0.0"},
  181. {:excoveralls, "~> 0.12.1", only: :test},
  182. {:flake_id, "~> 0.1.0"},
  183. {:remote_ip,
  184. git: "https://git.pleroma.social/pleroma/remote_ip.git",
  185. ref: "b647d0deecaa3acb140854fe4bda5b7e1dc6d1c8"},
  186. {:captcha,
  187. git: "https://git.pleroma.social/pleroma/elixir-libraries/elixir-captcha.git",
  188. ref: "e0f16822d578866e186a0974d65ad58cddc1e2ab"},
  189. {:mox, "~> 0.5", only: :test},
  190. {:restarter, path: "./restarter"},
  191. {:open_api_spex,
  192. git: "https://git.pleroma.social/pleroma/elixir-libraries/open_api_spex.git",
  193. ref: "f296ac0924ba3cf79c7a588c4c252889df4c2edd"}
  194. ] ++ oauth_deps()
  195. end
  196. # Aliases are shortcuts or tasks specific to the current project.
  197. # For example, to create, migrate and run the seeds file at once:
  198. #
  199. # $ mix ecto.setup
  200. #
  201. # See the documentation for `Mix` for more info on aliases.
  202. defp aliases do
  203. [
  204. "ecto.migrate": ["pleroma.ecto.migrate"],
  205. "ecto.rollback": ["pleroma.ecto.rollback"],
  206. "ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"],
  207. "ecto.reset": ["ecto.drop", "ecto.setup"],
  208. test: ["ecto.create --quiet", "ecto.migrate", "test"],
  209. docs: ["pleroma.docs", "docs"]
  210. ]
  211. end
  212. # Builds a version string made of:
  213. # * the application version
  214. # * a pre-release if ahead of the tag: the describe string (-count-commithash)
  215. # * branch name
  216. # * build metadata:
  217. # * a build name if `PLEROMA_BUILD_NAME` or `:pleroma, :build_name` is defined
  218. # * the mix environment if different than prod
  219. defp version(version) do
  220. identifier_filter = ~r/[^0-9a-z\-]+/i
  221. {_cmdgit, cmdgit_err} = System.cmd("sh", ["-c", "command -v git"])
  222. git_pre_release =
  223. if cmdgit_err == 0 do
  224. {tag, tag_err} =
  225. System.cmd("git", ["describe", "--tags", "--abbrev=0"], stderr_to_stdout: true)
  226. {describe, describe_err} = System.cmd("git", ["describe", "--tags", "--abbrev=8"])
  227. {commit_hash, commit_hash_err} = System.cmd("git", ["rev-parse", "--short", "HEAD"])
  228. # Pre-release version, denoted from patch version with a hyphen
  229. cond do
  230. tag_err == 0 and describe_err == 0 ->
  231. describe
  232. |> String.trim()
  233. |> String.replace(String.trim(tag), "")
  234. |> String.trim_leading("-")
  235. |> String.trim()
  236. commit_hash_err == 0 ->
  237. "0-g" <> String.trim(commit_hash)
  238. true ->
  239. nil
  240. end
  241. end
  242. # Branch name as pre-release version component, denoted with a dot
  243. branch_name =
  244. with 0 <- cmdgit_err,
  245. {branch_name, 0} <- System.cmd("git", ["rev-parse", "--abbrev-ref", "HEAD"]),
  246. branch_name <- String.trim(branch_name),
  247. branch_name <- System.get_env("PLEROMA_BUILD_BRANCH") || branch_name,
  248. true <-
  249. !Enum.any?(["master", "HEAD", "release/", "stable"], fn name ->
  250. String.starts_with?(name, branch_name)
  251. end) do
  252. branch_name =
  253. branch_name
  254. |> String.trim()
  255. |> String.replace(identifier_filter, "-")
  256. branch_name
  257. else
  258. _ -> ""
  259. end
  260. build_name =
  261. cond do
  262. name = Application.get_env(:pleroma, :build_name) -> name
  263. name = System.get_env("PLEROMA_BUILD_NAME") -> name
  264. true -> nil
  265. end
  266. env_name = if Mix.env() != :prod, do: to_string(Mix.env())
  267. env_override = System.get_env("PLEROMA_BUILD_ENV")
  268. env_name =
  269. case env_override do
  270. nil -> env_name
  271. env_override when env_override in ["", "prod"] -> nil
  272. env_override -> env_override
  273. end
  274. # Pre-release version, denoted by appending a hyphen
  275. # and a series of dot separated identifiers
  276. pre_release =
  277. [git_pre_release, branch_name]
  278. |> Enum.filter(fn string -> string && string != "" end)
  279. |> Enum.join(".")
  280. |> (fn
  281. "" -> nil
  282. string -> "-" <> String.replace(string, identifier_filter, "-")
  283. end).()
  284. # Build metadata, denoted with a plus sign
  285. build_metadata =
  286. [build_name, env_name]
  287. |> Enum.filter(fn string -> string && string != "" end)
  288. |> Enum.join(".")
  289. |> (fn
  290. "" -> nil
  291. string -> "+" <> String.replace(string, identifier_filter, "-")
  292. end).()
  293. [version, pre_release, build_metadata]
  294. |> Enum.filter(fn string -> string && string != "" end)
  295. |> Enum.join()
  296. end
  297. end