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.

250 lines
8.2KB

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