Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions lib/bootleg/tasks/build/docker.exs
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,11 @@ task :docker_generate_release do
docker_image = config(:docker_build_image)
docker_mount = config({:docker_build_mount, "#{source_path}:/opt/build"})
docker_run_options = config({:docker_build_opts, []})
release_args = config({:release_args, ["--quiet"]})
release_args = config({:release_args, []})
app_name = Config.app()

UI.info("Generating release...")

commands = [
["mix", ["distillery.release"] ++ release_args]
]

docker_args =
[
"run",
Expand All @@ -83,6 +80,11 @@ task :docker_generate_release do

UI.debug("Docker command prefix:\n " <> Enum.join(docker_args, " "))

commands = [
["mix", ["release"] ++ release_args],
["bash", ["-c", "cd _build/#{mix_env}/rel && tar -czvf #{app_name}.tar.gz #{app_name}/"]]
]

Enum.each(commands, fn [c, args] ->
UI.info("[docker] #{c} " <> Enum.join(args, " "))

Expand All @@ -106,7 +108,7 @@ task :docker_copy_release do
archive_path =
Path.join(
source_path,
"_build/#{mix_env}/rel/#{app_name}/releases/#{app_version}/#{app_name}.tar.gz"
"_build/#{mix_env}/rel/#{app_name}.tar.gz"
)

local_archive_folder = Path.join([File.cwd!(), "releases"])
Expand Down
19 changes: 9 additions & 10 deletions lib/bootleg/tasks/build/local.exs
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,18 @@ end
task :local_generate_release do
mix_env = config({:mix_env, "prod"})
source_path = config({:ex_path, File.cwd!()})
release_args = config({:release_args, ["--quiet"]})
release_args = config({:release_args, []})
app_name = Config.app()

UI.info("Generating release...")

commands = [
["mix", ["distillery.release"] ++ release_args]
]

File.cd!(source_path, fn ->
Enum.each(commands, fn [c, args] ->
UI.info("[local] #{c} " <> Enum.join(args, " "))
System.cmd(c, args, env: [{"MIX_ENV", mix_env}], into: IO.stream(:stdio, :line))
end)
UI.info("[local] mix release " <> Enum.join(release_args, " "))
System.cmd("mix", ["release"] ++ release_args, env: [{"MIX_ENV", mix_env}], into: IO.stream(:stdio, :line))

rel_dir = Path.join(source_path, "_build/#{mix_env}/rel")
UI.info("[local] tar -czvf #{app_name}.tar.gz #{app_name}/")
System.cmd("tar", ["-czvf", "#{app_name}.tar.gz", "#{app_name}/"], cd: rel_dir, into: IO.stream(:stdio, :line))
end)
end

Expand All @@ -56,7 +55,7 @@ task :local_copy_release do
archive_path =
Path.join(
source_path,
"_build/#{mix_env}/rel/#{app_name}/releases/#{app_version}/#{app_name}.tar.gz"
"_build/#{mix_env}/rel/#{app_name}.tar.gz"
)

local_archive_folder = Path.join([File.cwd!(), "releases"])
Expand Down
34 changes: 18 additions & 16 deletions lib/bootleg/tasks/build/remote.exs
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@ end
task :compile do
mix_env = config({:mix_env, "prod"})
source_path = config({:ex_path, ""})
app_name = Config.app()

UI.info("Building on remote server with mix env #{mix_env}...")
UI.info("Building on remote server with mix env #{mix_env}...")

remote :build, cd: source_path do
"MIX_ENV=#{mix_env} mix local.rebar --force"
"MIX_ENV=#{mix_env} mix local.hex --if-missing --force"
"MIX_ENV=#{mix_env} mix deps.get --only=#{mix_env}"
"MIX_ENV=#{mix_env} mix do clean, compile --force"
"MIX_ENV=#{mix_env} mix deps.get --only=#{mix_env} 2>&1 | grep -E \"^\(Resolving|[Ee]rror\)\" || true"
"MIX_ENV=#{mix_env} mix do clean, compile --force 2>&1 | grep -E \"^\(Generated #{app_name}|[Ee]rror\)\" || true"
end
end

Expand All @@ -63,14 +64,14 @@ task :remote_generate_release do
app_name = Config.app()

release_args =
{:release_args, ["--quiet"]}
{:release_args, []}
|> config()
|> Enum.join(" ")

UI.info("Generating release...")
UI.info("Generating release...")

remote :build, cd: source_path do
"MIX_ENV=#{mix_env} mix release #{release_args}"
"MIX_ENV=#{mix_env} mix release #{release_args} 2>&1 | grep -E \"^\(Generated|[Ee]rror\)\" || true"
end

source_path =
Expand All @@ -79,8 +80,9 @@ task :remote_generate_release do
"/_build/#{mix_env}/rel/"
])

UI.info("⚡ Creating Tarball...")
remote :build, cd: source_path do
"tar -czvf #{app_name}.tar.gz #{app_name}/"
"tar -czf #{app_name}.tar.gz #{app_name}/"
end
end

Expand All @@ -92,8 +94,9 @@ task :clean do
|> Enum.join(" ")

if locations != "" do
UI.info("⚡ Removing #{locations}...")
remote :build do
"rm -rvf #{locations}"
"rm -rf #{locations}"
end
end
end
Expand All @@ -108,13 +111,12 @@ task :copy_build_release do
source_path =
Path.join([
config({:ex_path, ""}),
"_build/#{mix_env}/rel/#{app_name}/releases/",
"#{app_version}/#{app_name}.tar.gz"
"_build/#{mix_env}/rel/#{app_name}.tar.gz"
])

dest_path = Path.join(release_workspace, "#{app_version}.tar.gz")

UI.info("Copying release archive to release workspace")
UI.info("Copying release archive to release workspace")

remote :build do
"mkdir -p #{release_workspace}"
Expand All @@ -137,17 +139,17 @@ task :download_release do
local_archive_folder = "#{File.cwd!()}/releases"
local_path = Path.join(local_archive_folder, "#{app_version}.tar.gz")

UI.info("Downloading release archive")
UI.info("Downloading release archive")
File.mkdir_p!(local_archive_folder)

download(:build, remote_path, local_path)

UI.info("Saved: releases/#{app_version}.tar.gz")
UI.info("Saved: releases/#{app_version}.tar.gz")
end

task :reset_remote do
refspec = config({:refspec, "master"})
UI.info("Resetting remote hosts to refspec \"#{refspec}\"")
UI.info("Resetting remote hosts to refspec \"#{refspec}\"")

remote :build do
"git reset --hard #{refspec}"
Expand Down Expand Up @@ -203,7 +205,7 @@ task :push_remote do
false -> []
end

UI.info("Pushing new commits with git to: #{user_host_port}")
UI.info("Pushing new commits with git to: #{user_host_port}")

case Git.push(["--tags", push_options, host_url, refspec], env: git_env) do
{"", 0} ->
Expand Down Expand Up @@ -295,7 +297,7 @@ task :pull_remote do
"/home/#{build_role.user}/#{workspace}"
end

UI.info("Pulling new commits with git from: #{repo_url}")
UI.info("Pulling new commits with git from: #{repo_url}")

remote :build, cd: "#{repo_path}/#{Config.app()}.git" do
"git remote set-url origin #{repo_url}"
Expand Down
7 changes: 2 additions & 5 deletions lib/bootleg/tasks/deploy.exs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,8 @@ end
#
task :unpack_release do
remote_path = "#{Config.app()}.tar.gz"
UI.info("Unpacking release archive")

UI.info("Unpacking release archive: #{remote_path}")
remote :app do
"tar -zxvf #{remote_path}"
"tar -zxf #{remote_path}"
end

UI.info("Unpacked release archive")
end
4 changes: 2 additions & 2 deletions lib/mix/tasks/init.ex
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ defmodule Mix.Tasks.Bootleg.Init do
use Bootleg.DSL

# Configure the following roles to match your environment.
# `build` defines what remote server your distillery release should be built on.
# `build` defines what remote server your release should be built on.
#
# Some available options are:
# - `user`: ssh username to use for SSH authentication to the role's hosts
Expand All @@ -38,7 +38,7 @@ defmodule Mix.Tasks.Bootleg.Init do
use Bootleg.DSL

# Configure the following roles to match your environment.
# `app` defines what remote servers your distillery release should be deployed and managed on.
# `app` defines what remote servers your release should be deployed and managed on.
#
# Some available options are:
# - `user`: ssh username to use for SSH authentication to the role's hosts
Expand Down
2 changes: 1 addition & 1 deletion lib/mix/tasks/ping.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Mix.Tasks.Bootleg.Ping do
@shortdoc "Pings an app."

@moduledoc """
Pings a deployed release using the `Distillery` helper.
Pings a deployed release.

# Usage:

Expand Down
2 changes: 1 addition & 1 deletion lib/mix/tasks/restart.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Mix.Tasks.Bootleg.Restart do
@shortdoc "Restarts a deployed release."

@moduledoc """
Restarts a deployed release using the `Distillery` helper.
Restarts a deployed release.

# Usage:

Expand Down
2 changes: 1 addition & 1 deletion lib/mix/tasks/start.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Mix.Tasks.Bootleg.Start do
@shortdoc "Starts a deployed release."

@moduledoc """
Starts a deployed release using the `Distillery` helper.
Starts a deployed release.

# Usage:

Expand Down
2 changes: 1 addition & 1 deletion lib/mix/tasks/stop.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Mix.Tasks.Bootleg.Stop do
@shortdoc "Stops a deployed release."

@moduledoc """
Stops a deployed release using the `Distillery` helper.
Stops a deployed release.

# Usage:

Expand Down
48 changes: 0 additions & 48 deletions test/fixtures/bootstraps/rel/config.exs

This file was deleted.

2 changes: 1 addition & 1 deletion test/fixtures/build_me/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ defmodule BuildMe.Mixfile do
#
# Type "mix help deps" for more examples and options
defp deps do
[{:distillery, "~> 2.1.0", runtime: false}]
[]
end
end
49 changes: 0 additions & 49 deletions test/fixtures/build_me/rel/config.exs

This file was deleted.

4 changes: 1 addition & 3 deletions test/fixtures/n00b/config/config.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# This file is responsible for configuring your application
# and its dependencies with the aid of the Mix.Config module.
use Mix.Config
import Config

# This configuration is loaded before any dependency and is restricted
# to this project. If another project depends on this project, this
Expand Down
1 change: 0 additions & 1 deletion test/fixtures/n00b/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ defmodule N00b.Mixfile do
# Type "mix help deps" for more examples and options
defp deps do
[
{:distillery, "~> 2.1.0", runtime: false},
{:bootleg, ">= 0.0.0", path: System.get_env("BOOTLEG_PATH"), runtime: false}
]
end
Expand Down
4 changes: 1 addition & 3 deletions test/fixtures/task_consumer/config/config.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# This file is responsible for configuring your application
# and its dependencies with the aid of the Mix.Config module.
use Mix.Config
import Config

# This configuration is loaded before any dependency and is restricted
# to this project. If another project depends on this project, this
Expand Down
1 change: 0 additions & 1 deletion test/fixtures/task_consumer/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ defmodule TaskConsumer.Mixfile do
# Type "mix help deps" for more examples and options
defp deps do
[
{:distillery, "~> 2.1.0", runtime: false},
{:task_provider, ">= 0.0.0", path: System.get_env("TASK_PROVIDER_PATH"), runtime: false},
{:bootleg, ">= 0.0.0", path: System.get_env("BOOTLEG_PATH"), runtime: false}
]
Expand Down
Loading