1 defmodule Pleroma.Mixfile do
7 version: version("2.6.2"),
9 elixirc_paths: elixirc_paths(Mix.env()),
10 compilers: Mix.compilers(),
11 elixirc_options: [warnings_as_errors: warnings_as_errors()],
12 xref: [exclude: [:eldap]],
13 dialyzer: [plt_add_apps: [:mix, :eldap]],
14 start_permanent: Mix.env() == :prod,
17 test_coverage: [tool: :covertool, summary: true],
20 homepage_url: "https://pleroma.social/",
21 source_url: "https://git.logografos.com/anni",
24 "https://git.logografos.com/?p=anni;a=summary",
25 logo: "priv/static/images/logo.png",
26 extras: ["README.md", "CHANGELOG.md"] ++ Path.wildcard("docs/**/*.md"),
28 "Installation manuals": Path.wildcard("docs/installation/*.md"),
29 Configuration: Path.wildcard("docs/config/*.md"),
30 Administration: Path.wildcard("docs/admin/*.md"),
31 "Pleroma's APIs and Mastodon API extensions": Path.wildcard("docs/api/*.md")
34 output: "priv/static/doc"
38 include_executables_for: [:unix],
39 applications: [ex_syslogger: :load, syslog: :load, eldap: :transient],
40 steps: [:assemble, &put_otp_version/1, ©_files/1, ©_nginx_config/1],
41 config_providers: [{Pleroma.Config.ReleaseRuntimeProvider, []}]
47 def put_otp_version(%{path: target_path} = release) do
49 Path.join([target_path, "OTP_VERSION"]),
50 Pleroma.OTPVersion.version()
56 def copy_files(%{path: target_path} = release) do
57 File.cp_r!("./rel/files", target_path)
61 def copy_nginx_config(%{path: target_path} = release) do
63 "./installation/pleroma.nginx",
64 Path.join([target_path, "installation", "pleroma.nginx"])
70 # Configuration for the OTP application.
72 # Type `mix help compile.app` for more information.
75 mod: {Pleroma.Application, []},
84 included_applications: [:ex_syslogger]
88 # Specifies which paths to compile per environment.
89 defp elixirc_paths(:benchmark), do: ["lib", "benchmarks", "priv/scrubbers"]
90 defp elixirc_paths(:test), do: ["lib", "test/support"]
91 defp elixirc_paths(_), do: ["lib"]
93 defp warnings_as_errors, do: System.get_env("CI") == "true"
95 # Specifies OAuth dependencies.
97 oauth_strategy_packages =
98 System.get_env("OAUTH_CONSUMER_STRATEGIES")
101 |> Enum.map(fn strategy_entry ->
102 with [_strategy, dependency] <- String.split(strategy_entry, ":") do
105 [strategy] -> "ueberauth_#{strategy}"
109 for s <- oauth_strategy_packages, do: {String.to_atom(s), ">= 0.0.0"}
112 # Specifies your project dependencies.
114 # Type `mix help deps` for examples and options.
117 {:phoenix, "~> 1.7.3"},
118 {:phoenix_ecto, "~> 4.4"},
119 {:ecto_sql, "~> 3.10"},
120 {:ecto_enum, "~> 1.4"},
121 {:postgrex, ">= 0.0.0"},
122 {:phoenix_html, "~> 3.3"},
123 {:phoenix_live_reload, "~> 1.3.3", only: :dev},
124 {:phoenix_live_view, "~> 0.19.0"},
125 {:phoenix_live_dashboard, "~> 0.8.0"},
126 {:telemetry_metrics, "~> 0.6"},
127 {:telemetry_poller, "~> 1.0"},
128 {:tzdata, "~> 1.0.3"},
129 {:plug_cowboy, "~> 2.5"},
130 # oban 2.14 requires Elixir 1.12+
131 {:oban, "~> 2.13.4"},
132 {:gettext, "~> 0.20"},
133 {:bcrypt_elixir, "~> 2.2"},
134 {:trailing_format_plug, "~> 0.0.7"},
135 {:fast_sanitize, "~> 0.2.0"},
136 {:html_entities, "~> 0.5", override: true},
137 {:calendar, "~> 1.0"},
139 {:poison, "~> 3.0", override: true},
140 {:tesla, "~> 1.8.0"},
141 {:castore, "~> 0.1"},
142 {:cowlib, "~> 2.9", override: true},
143 {:gun, "~> 2.0.0-rc.1", override: true},
146 {:mogrify, "~> 0.8.0"},
147 {:ex_aws, "~> 2.1.6"},
148 {:ex_aws_s3, "~> 2.0"},
149 {:sweet_xml, "~> 0.7.2"},
150 # earmark 1.4.23 requires Elixir 1.12+
151 {:earmark, "1.4.22"},
152 {:bbcode_pleroma, "~> 0.2.0"},
153 {:cors_plug, "~> 2.0"},
154 {:web_push_encryption, "~> 0.3.1"},
155 # swoosh 1.11.2+ requires Elixir 1.12+
156 {:swoosh, "~> 1.10.0"},
157 {:phoenix_swoosh, "~> 1.1"},
158 {:gen_smtp, "~> 0.13"},
159 {:ex_syslogger, "~> 1.4"},
162 {:ueberauth, "~> 0.4"},
164 git: "https://gitgud.io/mintplg/linkify.git",
165 branch: "domain-mention-parsing-fix"},
166 {:http_signatures, "~> 0.1.2"},
167 {:telemetry, "~> 1.0.0", override: true},
168 {:poolboy, "~> 1.5"},
169 {:prom_ex, "~> 1.9"},
173 {:ex_const, "~> 0.2"},
174 {:plug_static_index_html, "~> 1.0.0"},
175 {:flake_id, "~> 0.1.0"},
176 {:concurrent_limiter, "~> 0.1.1"},
178 git: "https://git.pleroma.social/pleroma/remote_ip.git",
179 ref: "b647d0deecaa3acb140854fe4bda5b7e1dc6d1c8"},
181 git: "https://git.pleroma.social/pleroma/elixir-libraries/elixir-captcha.git",
182 ref: "90f6ce7672f70f56708792a98d98bd05176c9176"},
183 {:restarter, path: "./restarter"},
185 {:open_api_spex, "~> 3.16"},
186 {:ecto_psql_extras, "~> 0.6"},
188 {:elixir_make, "~> 0.7.7", override: true},
189 {:blurhash, "~> 0.1.0", hex: :rinpatch_blurhash},
191 git: "https://github.com/akash-akya/exile.git",
192 ref: "be87c33b02a7c3c5d22d2ece01fbd462355b28ef"},
196 {:ex_doc, "~> 0.22", only: :dev, runtime: false},
197 {:ex_machina, "~> 2.4", only: :test},
198 {:credo, "~> 1.6", only: [:dev, :test], runtime: false},
199 {:mock, "~> 0.3.5", only: :test},
200 {:covertool, "~> 2.0", only: :test},
201 {:hackney, "~> 1.18.0", override: true},
202 {:mox, "~> 1.0", only: :test},
203 {:websockex, "~> 0.4.3", only: :test},
204 {:benchee, "~> 1.0", only: :benchmark},
205 {:dialyxir, "~> 1.4", only: [:dev, :test], runtime: false}
209 # Aliases are shortcuts or tasks specific to the current project.
210 # For example, to create, migrate and run the seeds file at once:
214 # See the documentation for `Mix` for more info on aliases.
217 "ecto.migrate": ["pleroma.ecto.migrate"],
218 "ecto.rollback": ["pleroma.ecto.rollback"],
219 "ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"],
220 "ecto.reset": ["ecto.drop", "ecto.setup"],
221 test: ["ecto.create --quiet", "ecto.migrate", "test"],
222 docs: ["pleroma.docs", "docs"],
223 analyze: ["credo --strict --only=warnings,todo,fixme,consistency,readability"],
224 copyright: &add_copyright/1,
225 "copyright.bump": &bump_copyright/1
229 # Builds a version string made of:
230 # * the application version
231 # * a pre-release if ahead of the tag: the describe string (-count-commithash)
234 # * a build name if `PLEROMA_BUILD_NAME` or `:pleroma, :build_name` is defined
235 # * the mix environment if different than prod
236 defp version(version) do
237 identifier_filter = ~r/[^0-9a-z\-]+/i
239 git_available? = match?({_output, 0}, System.cmd("sh", ["-c", "command -v git"]))
240 dotgit_present? = File.exists?(".git")
243 if git_available? and dotgit_present? do
245 System.cmd("git", ["describe", "--tags", "--abbrev=0"], stderr_to_stdout: true)
247 {describe, describe_err} = System.cmd("git", ["describe", "--tags", "--abbrev=8"])
248 {commit_hash, commit_hash_err} = System.cmd("git", ["rev-parse", "--short", "HEAD"])
250 # Pre-release version, denoted from patch version with a hyphen
252 tag_err == 0 and describe_err == 0 ->
255 |> String.replace(String.trim(tag), "")
256 |> String.trim_leading("-")
259 commit_hash_err == 0 ->
260 "0-g" <> String.trim(commit_hash)
267 # Branch name as pre-release version component, denoted with a dot
269 with true <- git_available?,
270 true <- dotgit_present?,
271 {branch_name, 0} <- System.cmd("git", ["rev-parse", "--abbrev-ref", "HEAD"]),
272 branch_name <- String.trim(branch_name),
273 branch_name <- System.get_env("PLEROMA_BUILD_BRANCH") || branch_name,
275 !Enum.any?(["master", "HEAD", "release/", "stable"], fn name ->
276 String.starts_with?(name, branch_name)
281 |> String.replace(identifier_filter, "-")
290 name = Application.get_env(:pleroma, :build_name) -> name
291 name = System.get_env("PLEROMA_BUILD_NAME") -> name
295 env_name = if Mix.env() != :prod, do: to_string(Mix.env())
296 env_override = System.get_env("PLEROMA_BUILD_ENV")
301 env_override when env_override in ["", "prod"] -> nil
302 env_override -> env_override
305 # Pre-release version, denoted by appending a hyphen
306 # and a series of dot separated identifiers
308 [git_pre_release, branch_name]
309 |> Enum.filter(fn string -> string && string != "" end)
313 string -> "-" <> String.replace(string, identifier_filter, "-")
316 # Build metadata, denoted with a plus sign
318 [build_name, env_name]
319 |> Enum.filter(fn string -> string && string != "" end)
323 string -> "+" <> String.replace(string, identifier_filter, "-")
326 [version, pre_release, build_metadata]
327 |> Enum.filter(fn string -> string && string != "" end)
331 defp add_copyright(_) do
332 year = NaiveDateTime.utc_now().year
334 # Pleroma: A lightweight social networking server
335 # Copyright © 2017-#{year} Pleroma Authors <https://pleroma.social/>
336 # SPDX-License-Identifier: AGPL-3.0-only
338 ] |> String.replace("\n", "\\n")
340 find = "find lib test priv -type f \\( -name '*.ex' -or -name '*.exs' \\) -exec "
341 grep = "grep -L '# Copyright © [0-9\-]* Pleroma' {} \\;"
342 xargs = "xargs -n1 sed -i'' '1s;^;#{template};'"
344 :os.cmd(String.to_charlist("#{find}#{grep} | #{xargs}"))
347 defp bump_copyright(_) do
348 year = NaiveDateTime.utc_now().year
349 find = "find lib test priv -type f \\( -name '*.ex' -or -name '*.exs' \\)"
352 "xargs sed -i'' 's;# Copyright © [0-9\-]* Pleroma.*$;# Copyright © 2017-#{year} Pleroma Authors <https://pleroma.social/>;'"
354 :os.cmd(String.to_charlist("#{find} | #{xargs}"))