Files
n8n-openai-adapter/.github/workflows/notify.exs
T
Thanabodee Charoenpiriyakij aca6ebd6e1 Strip name from checksum file (#11561)
Currently, the notify.exs will generate the checksum to:

```
  * Docs.zip - sha1sum - 3812e2db7c71a6a8b03b75d06ca6debb46aebc55  Docs.zip

  * Docs.zip - sha256sum - cafe86adc01fcc700c83f353aedf746eeffd3b6e1542cedff18af64956ae539b  Docs.zip

  * elixir-otp-23.zip - sha1sum - 35f999b98cbfa5888fefbeafaaf73f661a903bb7  elixir-otp-23.zip

  * elixir-otp-23.zip - sha256sum - 11f970adc3ddc759f349b0e00b6aecd06a1d460f21488d2ffe8f6738f2518728  elixir-otp-23.zip

  * elixir-otp-24.zip - sha1sum - c4224ce1b78247d7c5e04c7cd4576496fd49f002  elixir-otp-24.zip

  * elixir-otp-24.zip - sha256sum - 677fe7a147a40e5ee876eeb7bb8e4b968d2a8a9c42793561b61a08269ca91c19  elixir-otp-24.zip
```

The result have a file name and newline at the end of each line. This change strip
that, so the result will be:

```
  * Docs.zip - sha1sum - 3812e2db7c71a6a8b03b75d06ca6debb46aebc55
  * Docs.zip - sha256sum - cafe86adc01fcc700c83f353aedf746eeffd3b6e1542cedff18af64956ae539b
  * elixir-otp-23.zip - sha1sum - 35f999b98cbfa5888fefbeafaaf73f661a903bb7
  * elixir-otp-23.zip - sha256sum - 11f970adc3ddc759f349b0e00b6aecd06a1d460f21488d2ffe8f6738f2518728
  * elixir-otp-24.zip - sha1sum - c4224ce1b78247d7c5e04c7cd4576496fd49f002
  * elixir-otp-24.zip - sha256sum - 677fe7a147a40e5ee876eeb7bb8e4b968d2a8a9c42793561b61a08269ca91c19
```
2022-01-10 12:13:24 +01:00

63 lines
1.7 KiB
Elixir

# #!/usr/bin/env elixir
[tag] = System.argv()
Mix.install([
{:req, "~> 0.2.1"},
{:jason, "~> 1.0"}
])
%{status: 200, body: body} =
Req.get!("https://api.github.com/repos/elixir-lang/elixir/releases/tags/#{tag}")
if body["draft"] do
raise "cannot notify a draft release"
end
## Notify on elixir-lang-ann
names_and_checksums =
for asset <- body["assets"],
name = asset["name"],
name =~ ~r/.sha\d+sum$/,
do: {name, Req.get!(asset["browser_download_url"]).body}
line_items =
for {name, checksum_and_name} <- Enum.sort(names_and_checksums) do
[checksum | _] = String.split(checksum_and_name, " ")
root = Path.rootname(name)
"." <> type = Path.extname(name)
" * #{root} - #{type} - #{checksum}\n"
end
headers = %{
"X-Postmark-Server-Token" => System.fetch_env!("ELIXIR_LANG_ANN_TOKEN")
}
body = %{
"From" => "jose.valim@dashbit.co",
"To" => "elixir-lang-ann@googlegroups.com",
"Subject" => "Elixir #{tag} released",
"HtmlBody" => "https://github.com/elixir-lang/elixir/releases/tag/#{tag}\n\n#{line_items}",
"MessageStream": "outbound"
}
resp = Req.post!("https://api.postmarkapp.com/email", {:json, body}, headers: headers)
IO.puts("#{resp.status} elixir-lang-ann\n#{inspect(resp.body)}")
## Notify on Elixir Forum
headers = %{
"api-key" => System.fetch_env!("ELIXIR_FORUM_TOKEN"),
"api-username" => "Elixir"
}
body = %{
"title" => "Elixir #{tag} released",
"raw" => "https://github.com/elixir-lang/elixir/releases/tag/#{tag}\n\n#{body["body"]}",
# Elixir News
"category" => 28
}
resp = Req.post!("https://elixirforum.com/posts.json", {:json, body}, headers: headers)
IO.puts("#{resp.status} Elixir Forum\n#{inspect(resp.body)}")