-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add deploy script and updated deploy instructions to the README (…
- Loading branch information
1 parent
5168fd7
commit 4712312
Showing
2 changed files
with
80 additions
and
32 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
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,45 @@ | ||
defmodule Mix.Tasks.Deploy.Prod do | ||
@moduledoc """ | ||
Open the Github Releases page that triggers a production deploy | ||
""" | ||
use Mix.Task | ||
|
||
@shortdoc "Open the Github Releases page that allows us to trigger a production deploy" | ||
@spec run([binary]) :: any | ||
def run(_) do | ||
System.cmd("git", ["fetch"]) | ||
|
||
latest_tag = | ||
System.cmd("git", ["describe", "origin/main", "--tags", "--abbrev=0"]) | ||
|> case do | ||
{tag, 0} -> tag | ||
end | ||
|> String.trim() | ||
|
||
%{"previous_date" => previous_date, "previous_count" => previous_count} = | ||
Regex.named_captures(~r/(?<previous_date>.*)-(?<previous_count>\d)/, latest_tag) | ||
|
||
today = Date.to_string(Date.utc_today()) | ||
|
||
count = | ||
1 + | ||
case today do | ||
^previous_date -> | ||
previous_count | ||
|> Integer.parse() | ||
|> case do | ||
{previous_count, ""} -> | ||
previous_count | ||
end | ||
|
||
_ -> | ||
0 | ||
end | ||
|
||
new_release = "#{today}-#{count}" | ||
|
||
System.cmd("open", [ | ||
"https://github.com/mbta/skate/releases/new?tag=#{new_release}" | ||
]) | ||
end | ||
end |