       Keyword.get(overrides, :silent, false)  -> :silent
       :else -> verbosity
     end
+    {rel, env} = case Keyword.get(overrides, :profile) do
+      nil ->
+        rel = Keyword.get(overrides, :name, :default)
+        env = Keyword.get(overrides, :env, :default)
+        {rel, env}
+      profile ->
+        case String.split(profile, ":", trim: true, parts: 2) do
+          [rel, env] -> {rel, env}
+          other ->
+            Logger.error "invalid profile name `#{other}`, must be `name:env`"
+            exit({:shutdown, 1})
+        end
+    end
     [verbosity: verbosity,
-     selected_release: Keyword.get(overrides, :name, :default),
-     selected_environment: Keyword.get(overrides, :env, :default),
+     selected_release: rel,
+     selected_environment: env,
      dev_mode: Keyword.get(overrides, :dev),
      erl_opts: Keyword.get(overrides, :erl),
      no_tar:   Keyword.get(overrides, :no_tar, false),

          other ->
            Logger.error "Problem generating release tarball:\n    " <>
              "#{inspect other}"
        end
      {{:error, reason},_} when is_binary(reason) ->
        Logger.error "Failed to build release:\n    " <>
          reason
      {{:error, reason},_} ->
        Logger.error "Failed to build release:\n    " <>
          "#{inspect reason}"
    end
  end



      # Build a release for a specific environment
      mix release --env=staging

      # Build a specific profile
      mix release --profile=myapp:staging

      # Pass args to erlexec when running the release
      mix release --erl="-env TZ UTC"
