-
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add mix tasks for generating release artifacts (#119)
- Loading branch information
Showing
7 changed files
with
159 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,3 +33,5 @@ npm-debug.log | |
/assets/node_modules/ | ||
|
||
burrito_out/* | ||
|
||
supavisor-*.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ dev.node2: | |
SECRET_KEY_BASE="dev" \ | ||
CLUSTER_POSTGRES="true" \ | ||
ERL_AFLAGS="-kernel shell_history enabled" \ | ||
iex --name [email protected] --cookie cookie -S mix phx.server | ||
iex --name [email protected] --cookie cookie -S mix phx.server | ||
|
||
dev_bin: | ||
MIX_ENV=dev mix release supavisor_bin && ls -l burrito_out | ||
|
@@ -55,3 +55,26 @@ pgbench_short: | |
|
||
pgbench_long: | ||
PGPASSWORD=postgres pgbench -M extended --transactions 100 --jobs 10 --client 60 -h localhost -p 7654 -U transaction.localhost postgres | ||
|
||
clean: | ||
rm -rf _build && rm -rf deps | ||
|
||
dev_release: | ||
mix deps.get && mix compile && mix release supavisor | ||
|
||
dev_up: | ||
rm -rf _build/dev/lib/supavisor && \ | ||
MIX_ENV=dev mix compile && \ | ||
mix release supavisor | ||
|
||
dev_start_rel: | ||
MIX_ENV=dev \ | ||
VAULT_ENC_KEY="aHD8DZRdk2emnkdktFZRh3E9RNg4aOY7" \ | ||
API_JWT_SECRET=dev \ | ||
METRICS_JWT_SECRET=dev \ | ||
REGION=eu \ | ||
FLY_ALLOC_ID=111e4567-e89b-12d3-a456-426614174000 \ | ||
SECRET_KEY_BASE="dev" \ | ||
CLUSTER_POSTGRES="true" \ | ||
ERL_AFLAGS="-kernel shell_history enabled" \ | ||
./_build/dev/rel/supavisor/bin/supavisor start_iex |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.2.9 | ||
0.2.10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
defmodule Mix.Tasks.Supavisor.Gen.Appup do | ||
@moduledoc """ | ||
Generates an appup file for a given release. | ||
## Examples | ||
# Generate an appup from 0.0.1 to 0.0.2 versions | ||
mix supavisor.gen.appup --from=0.0.1 --to=0.0.2 | ||
""" | ||
|
||
use Mix.Task | ||
alias Distillery.Releases.Appup | ||
|
||
@impl true | ||
def run(args) do | ||
{parsed, _, _} = OptionParser.parse(args, strict: [from: :string, to: :string]) | ||
|
||
{from_vsn, to_vsn} = | ||
if !parsed[:from] || !parsed[:to] do | ||
Mix.Task.run("help", ["supavisor.gen.appup"]) | ||
System.halt(1) | ||
else | ||
{parsed[:from], parsed[:to]} | ||
end | ||
|
||
IO.puts("Generating appup from #{from_vsn} to #{to_vsn}...\n") | ||
|
||
rel_dir = Path.join([File.cwd!(), "_build", "#{Mix.env()}", "rel", "supavisor"]) | ||
lib_path = Path.join(rel_dir, "lib") | ||
path_from = Path.join(lib_path, "supavisor-#{from_vsn}") | ||
path_to = Path.join(lib_path, "supavisor-#{to_vsn}") | ||
appup_path = Path.join([path_to, "ebin", "supavisor.appup"]) | ||
|
||
case Appup.make(:supavisor, from_vsn, to_vsn, path_from, path_to) do | ||
{:ok, appup} -> | ||
IO.puts("Writing appup to #{appup_path}") | ||
|
||
case File.write(appup_path, :io_lib.format("~p.", [appup]), [:utf8]) do | ||
:ok -> | ||
IO.puts("Appup:\n#{File.read!(appup_path)}") | ||
|
||
{:error, reason} -> | ||
Mix.raise("Failed to write appup file: #{reason}") | ||
end | ||
|
||
{:error, reason} -> | ||
Mix.raise("Failed to generate appup file: #{inspect(reason)}") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
defmodule Mix.Tasks.Supavisor.Gen.Relup do | ||
@moduledoc """ | ||
Generates an appup file for a given release. | ||
## Examples | ||
# Generate an appup from 0.0.1 to 0.0.2 versions | ||
mix supavisor.gen.appup --from=0.0.1 --to=0.0.2 | ||
""" | ||
|
||
use Mix.Task | ||
|
||
@impl true | ||
def run(args) do | ||
{parsed, _, _} = OptionParser.parse(args, strict: [from: :string, to: :string]) | ||
|
||
{from_vsn, to_vsn} = | ||
if !parsed[:from] || !parsed[:to] do | ||
Mix.Task.run("help", ["supavisor.gen.relup"]) | ||
System.halt(1) | ||
else | ||
{parsed[:from], parsed[:to]} | ||
end | ||
|
||
IO.puts("Generating relup from #{from_vsn} to #{to_vsn}...\n") | ||
|
||
rel_dir = Path.join([File.cwd!(), "_build", "#{Mix.env()}", "rel", "supavisor"]) | ||
prev_rel_dir = Path.join([rel_dir, "releases", from_vsn]) | ||
curr_rel_dir = Path.join([rel_dir, "releases", to_vsn]) | ||
lib_path = Path.join(rel_dir, "lib") | ||
relup_path = Path.join(curr_rel_dir, "relup") | ||
|
||
opts = [ | ||
{:path, [Path.join(lib_path, "*/ebin") |> to_charlist()]}, | ||
{:outdir, to_charlist(curr_rel_dir)} | ||
] | ||
|
||
rel1 = Path.join(prev_rel_dir, "supavisor") |> to_charlist() | ||
rel2 = Path.join(curr_rel_dir, "supavisor") |> to_charlist() | ||
|
||
case :systools.make_relup(rel2, [rel1], [rel1], opts) do | ||
:ok -> | ||
IO.puts("Writing relup to #{relup_path}\n") | ||
|
||
case File.read(relup_path) do | ||
{:ok, content} -> | ||
IO.puts("Relup:\n#{content}") | ||
|
||
{:error, reason} -> | ||
Mix.raise("Failed to read relup file: #{reason}") | ||
end | ||
|
||
other -> | ||
Mix.raise("Failed to generate relup file: #{other}") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters