Skip to content

Commit

Permalink
new version and better publisher
Browse files Browse the repository at this point in the history
  • Loading branch information
eliasdarruda committed Nov 3, 2022
1 parent e10bd85 commit 28824c9
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 81 deletions.
2 changes: 1 addition & 1 deletion .formatter.exs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Used by "mix format"
[
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"],
inputs: ["{.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"],
subdirectories: ["lib/*", "spawn_*/*", "test/*"]
]
34 changes: 7 additions & 27 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -77,33 +77,13 @@ defmodule Spawn.MixProject do
{:faker, "~> 0.17", only: :test},
{:mimic, "~> 1.7", only: :test},
{:ex_doc, ">= 0.0.0", only: :dev, runtime: false},
{:pluggable, "~> 1.0.1", only: :dev, runtime: false}
] ++
InternalVersions.internal_dep(
:spawn_statestores_mssql,
[path: "./spawn_statestores/statestores_mssql", optional: false],
optional: true
) ++
InternalVersions.internal_dep(
:spawn_statestores_mysql,
[path: "./spawn_statestores/statestores_mysql", optional: false],
optional: true
) ++
InternalVersions.internal_dep(
:spawn_statestores_postgres,
[path: "./spawn_statestores/statestores_postgres", optional: false],
optional: true
) ++
InternalVersions.internal_dep(
:spawn_statestores_sqlite,
[path: "./spawn_statestores/statestores_sqlite", optional: false],
optional: true
) ++
InternalVersions.internal_dep(
:spawn_statestores_cockroachdb,
[path: "./spawn_statestores/statestores_cockroachdb", optional: false],
optional: true
)
{:pluggable, "~> 1.0.1", only: :dev, runtime: false},
{:spawn_statestores_mssql, path: "./spawn_statestores/statestores_mssql", optional: false},
{:spawn_statestores_mysql, path: "./spawn_statestores/statestores_mysql", optional: false},
{:spawn_statestores_postgres, path: "./spawn_statestores/statestores_postgres", optional: false},
{:spawn_statestores_sqlite, path: "./spawn_statestores/statestores_sqlite", optional: false},
{:spawn_statestores_cockroachdb, path: "./spawn_statestores/statestores_cockroachdb", optional: false}
]
end

defp elixirc_paths(:test),
Expand Down
92 changes: 57 additions & 35 deletions priv/internal_versions.exs
Original file line number Diff line number Diff line change
@@ -1,39 +1,26 @@
defmodule InternalVersions do
# The order here is also the deploy order, its important to keep this way
@versions [
spawn_statestores: "0.5.0-alpha.3",
spawn_statestores_mysql: "0.5.0-alpha.3",
spawn_statestores_mssql: "0.5.0-alpha.3",
spawn_statestores_postgres: "0.5.0-alpha.3",
spawn_statestores_sqlite: "0.5.0-alpha.3",
spawn_statestores_cockroachdb: "0.5.0-alpha.3",
spawn: "0.5.0-alpha.3",
spawn_sdk: "0.5.0-alpha.3",

activator: "0.5.0-alpha.3",
activator_grpc: "0.5.0-alpha.3",
activator_http: "0.5.0-alpha.3",
activator_kafka: "0.5.0-alpha.3",
activator_pubsub: "0.5.0-alpha.3",
activator_rabbitmq: "0.5.0-alpha.3",
activator_sqs: "0.5.0-alpha.3",

proxy: "0.5.0-alpha.3"
spawn_statestores: "0.5.0-alpha.4",
spawn_statestores_mysql: "0.5.0-alpha.4",
spawn_statestores_mssql: "0.5.0-alpha.4",
spawn_statestores_postgres: "0.5.0-alpha.4",
spawn_statestores_sqlite: "0.5.0-alpha.4",
spawn_statestores_cockroachdb: "0.5.0-alpha.4",
spawn: "0.5.0-alpha.4",
spawn_sdk: "0.5.0-alpha.4",

activator: "0.5.0-alpha.4",
activator_grpc: "0.5.0-alpha.4",
activator_http: "0.5.0-alpha.4",
activator_kafka: "0.5.0-alpha.4",
activator_pubsub: "0.5.0-alpha.4",
activator_rabbitmq: "0.5.0-alpha.4",
activator_sqs: "0.5.0-alpha.4",

proxy: "0.5.0-alpha.4"
]

def get(app_name) do
Keyword.fetch!(@versions, app_name)
end

@is_release System.get_env("SPAWN_RELEASE")
def internal_dep(app_name, path_opts \\ [], release_opts \\ []) do
if @is_release do
[{app_name, "~> #{get(app_name)}", release_opts}]
else
[{app_name, path_opts}]
end
end

@doc """
RUN before anything else:
Expand Down Expand Up @@ -94,20 +81,55 @@ defmodule InternalVersions do
{"./", "."}
end

whole_command = "SPAWN_RELEASE=true cd #{dir} \
&& SPAWN_RELEASE=true mix deps.get \
&& HEX_API_KEY=#{key} SPAWN_RELEASE=true mix hex.publish --yes #{replace?} #{dry_run?} \
whole_command = "cd #{dir} \
&& mix deps.get \
&& HEX_API_KEY=#{key} mix hex.publish --yes #{replace?} #{dry_run?} \
&& cd #{dir_back}"

IO.puts("- Releasing #{inspect(app)}")

mix_file = File.read!("#{dir}/mix.exs")
File.write!("#{dir}/mix.exs", String.replace(mix_file, "0.0.0-local.dev", version))

match_spawn_with_path = ~r(\{:spawn,\s*path:.*\})
match_spawn_statestores_with_path = ~r(\{:spawn_statestores,\s*path:.*\})
match_spawn_mysql_with_path = ~r(\{:spawn_statestores_mysql,\s*path:.*\})
match_spawn_mssql_with_path = ~r(\{:spawn_statestores_mssql,\s*path:.*\})
match_spawn_postgres_with_path = ~r(\{:spawn_statestores_postgres,\s*path:.*\})
match_spawn_cockroachdb_with_path = ~r(\{:spawn_statestores_cockroachdb,\s*path:.*\})
match_spawn_sqlite_with_path = ~r(\{:spawn_statestores_sqlite,\s*path:.*\})

new_mix_exs = mix_file
|> String.replace(match_spawn_with_path, dep_for("spawn"), global: false)
|> String.replace(match_spawn_statestores_with_path, dep_for("spawn_statestores"), global: false)
|> String.replace(match_spawn_mysql_with_path, dep_for("spawn_statestores_mysql", true), global: false)
|> String.replace(match_spawn_mssql_with_path, dep_for("spawn_statestores_mssql", true), global: false)
|> String.replace(match_spawn_postgres_with_path, dep_for("spawn_statestores_postgres", true), global: false)
|> String.replace(match_spawn_cockroachdb_with_path, dep_for("spawn_statestores_cockroachdb", true), global: false)
|> String.replace(match_spawn_sqlite_with_path, dep_for("spawn_statestores_sqlite", true), global: false)
|> String.replace("0.0.0-local.dev", version)

File.write!("#{dir}/mix.exs", new_mix_exs)

System.shell(whole_command, into: IO.stream())

IO.puts("-- Waiting some time to publish #{inspect(app)}...")
Process.sleep(3_000)
end)
end

defp get(app_name) do
Keyword.fetch!(@versions, app_name)
end

defp get_version(app_name) do
"~> #{get(String.to_existing_atom(app_name))}"
end

defp dep_for(app_name, optional? \\ false) do
if optional? do
"{:#{app_name}, \"#{get_version(app_name)}\", optional: true}"
else
"{:#{app_name}, \"#{get_version(app_name)}\"}"
end
end
end
6 changes: 3 additions & 3 deletions spawn_sdk/spawn_sdk/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ defmodule SpawnSdk.MixProject do
defp deps do
[
{:faker, "~> 0.17", only: :test},
{:ex_doc, ">= 0.0.0", only: :dev, runtime: false}
] ++
InternalVersions.internal_dep(:spawn, path: "../../")
{:ex_doc, ">= 0.0.0", only: :dev, runtime: false},
{:spawn, path: "../.."}
]
end

defp elixirc_paths(:test), do: ["lib", "test/support"]
Expand Down
6 changes: 3 additions & 3 deletions spawn_statestores/statestores_cockroachdb/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ defmodule StatestoresCockroachDB.MixProject do
{:cloak_ecto, "~> 1.2"},
{:ecto_sql, "~> 3.8"},
{:ex_doc, ">= 0.0.0", only: :dev, runtime: false},
{:postgrex, "~> 0.16"}
] ++
InternalVersions.internal_dep(:spawn_statestores, path: "../statestores")
{:postgrex, "~> 0.16"},
{:spawn_statestores, path: "../statestores"}
]
end

defp elixirc_paths(:test), do: ["lib", "test/support"]
Expand Down
6 changes: 3 additions & 3 deletions spawn_statestores/statestores_mssql/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ defmodule StatestoresMssql.MixProject do
{:cloak_ecto, "~> 1.2"},
{:ecto_sql, "~> 3.8"},
{:ex_doc, ">= 0.0.0", only: :dev, runtime: false},
{:tds, "~> 2.3"}
] ++
InternalVersions.internal_dep(:spawn_statestores, path: "../statestores")
{:tds, "~> 2.3"},
{:spawn_statestores, path: "../statestores"}
]
end

defp elixirc_paths(:test), do: ["lib", "test/support"]
Expand Down
6 changes: 3 additions & 3 deletions spawn_statestores/statestores_mysql/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ defmodule StatestoresMysql.MixProject do
{:cloak_ecto, "~> 1.2"},
{:ecto_sql, "~> 3.8"},
{:ex_doc, ">= 0.0.0", only: :dev, runtime: false},
{:myxql, "~> 0.6"}
] ++
InternalVersions.internal_dep(:spawn_statestores, path: "../statestores")
{:myxql, "~> 0.6"},
{:spawn_statestores, path: "../statestores"}
]
end

defp elixirc_paths(:test), do: ["lib", "test/support"]
Expand Down
6 changes: 3 additions & 3 deletions spawn_statestores/statestores_postgres/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ defmodule StatestoresPostgres.MixProject do
{:cloak_ecto, "~> 1.2"},
{:ecto_sql, "~> 3.8"},
{:ex_doc, ">= 0.0.0", only: :dev, runtime: false},
{:postgrex, "~> 0.16"}
] ++
InternalVersions.internal_dep(:spawn_statestores, path: "../statestores")
{:postgrex, "~> 0.16"},
{:spawn_statestores, path: "../statestores"}
]
end

defp elixirc_paths(:test), do: ["lib", "test/support"]
Expand Down
6 changes: 3 additions & 3 deletions spawn_statestores/statestores_sqlite/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ defmodule StatestoresSqlite.MixProject do
{:cloak_ecto, "~> 1.2"},
{:ecto_sql, "~> 3.8"},
{:ex_doc, ">= 0.0.0", only: :dev, runtime: false},
{:ecto_sqlite3, "~> 0.8.2"}
] ++
InternalVersions.internal_dep(:spawn_statestores, path: "../statestores")
{:ecto_sqlite3, "~> 0.8.2"},
{:spawn_statestores, path: "../statestores"}
]
end

defp elixirc_paths(:test), do: ["lib", "test/support"]
Expand Down

0 comments on commit 28824c9

Please sign in to comment.