   """
   defmacro current_version(app) do
     quote do
-      unless is_atom(unquote(app)) do
-        raise "current_version argument must be an atom! got #{inspect(unquote(app))}"
-      end
-
-      Application.load(unquote(app))
-
-      case Application.spec(unquote(app)) do
-        nil -> raise "could not get current version of #{unquote(app)}, app could not be loaded"
-        spec -> "#{Keyword.get(spec, :vsn)}"
+      app = unquote(app)
+
+      unless is_atom(app) do
+        raise "current_version argument must be an atom! got #{inspect(app)}"
+      end
+
+      Application.load(app)
+
+      case Application.spec(app) do
+        nil ->
+          raise "could not get current version of #{app}, app could not be loaded"
+
+        spec ->
+          "#{Keyword.get(spec, :vsn)}"
       end
     end
   end

        raise "cannot use set/1 outside of an environment or a release!"
      end

      config = Mix.Config.Agent.get(var!(config_agent, Mix.Releases.Config))

      cond do
        current_env != nil ->
          env = get_in(config, [:environments, current_env])

          env =
            Enum.reduce(unquote(opts), env, fn {k, v}, acc ->
              case Map.has_key?(acc.profile, k) do
                false ->
                  raise "unknown environment config setting `#{k}`"

                true ->
                  %{acc | :profile => Map.put(acc.profile, k, v)}
              end
            end)

          Mix.Config.Agent.merge(
            var!(config_agent, Mix.Releases.Config),
            environments: [{current_env, env}]
          )

        current_rel != nil ->
          rel = get_in(config, [:releases, current_rel])

          rel =
            Enum.reduce(unquote(opts), rel, fn
              {:version, v}, acc ->
                %{acc | :version => v}

              {:applications, v}, acc ->
                %{acc | :applications => acc.applications ++ v}

              {k, v}, acc ->
                case Map.has_key?(acc.profile, k) do
                  false ->
                    raise "unknown release config setting `#{k}`"

                  true ->
                    %{acc | :profile => Map.put(acc.profile, k, v)}
                end
            end)

          Mix.Config.Agent.merge(
            var!(config_agent, Mix.Releases.Config),
            releases: [{current_rel, rel}]
          )
      end
    end
  end


  """
  defmacro environment(name, do: block) do
    quote do
      name = unquote(name)

      unless is_atom(name) do
        raise "environment name must be an atom! got #{inspect(name)}"
      end

      env = Environment.new(name)
      conf = var!(config, Mix.Releases.Config)
      var!(config, Mix.Releases.Config) = put_in(conf, [:environments, name], env)
      var!(current_env, Mix.Releases.Config) = name
      unquote(block)
      var!(current_env, Mix.Releases.Config) = nil
    end
