Routes generated by a custom macro disappear when using releases

Suppose we’ve got the following code in the router:

scope "/" do

and a macro that generates the route AST:

defmacro my_route_macro do
  quote do
    get "/my-route", MyController, :my_route

Now, when I run this locally:
$ mix phx.server
everything works fine, Phoenix displays the routes:
$ mix phx.routes
and matches the URL correctly.

But when I build and run a release:

$ mix release
$ _build/path_to_my_release start

the given route is not present.

How can this be? Am I doing something wrong?