diff options
author | José Valim <jose.valim@dashbit.co> | 2021-12-30 16:42:39 +0100 |
---|---|---|
committer | José Valim <jose.valim@dashbit.co> | 2021-12-30 16:42:39 +0100 |
commit | 1ff7e48f1deeff2215356945d5d60de4a131baf6 (patch) | |
tree | dcf3599cceb55a40f5bdd5ce5f053128ecadf9ea /.github | |
parent | 222d43f324396fcd972d962631176fbe30f5b301 (diff) | |
download | elixir-1ff7e48f1deeff2215356945d5d60de4a131baf6.tar.gz |
Automate notifications
Diffstat (limited to '.github')
-rw-r--r-- | .github/workflows/mail.exs | 21 | ||||
-rw-r--r-- | .github/workflows/notify.exs | 61 | ||||
-rw-r--r-- | .github/workflows/notify.yml | 25 | ||||
-rw-r--r-- | .github/workflows/release.yml | 1 |
4 files changed, 87 insertions, 21 deletions
diff --git a/.github/workflows/mail.exs b/.github/workflows/mail.exs deleted file mode 100644 index b78d447c7..000000000 --- a/.github/workflows/mail.exs +++ /dev/null @@ -1,21 +0,0 @@ -# #!/usr/bin/env elixir -[tag] = System.argv() -Mix.install([:req, :jason]) - -%{status: 200, body: body} = - Req.get!("https://api.github.com/repos/elixir-lang/elixir/releases/tags/#{tag}") - -names_and_checksums = - for asset <- body["assets"], - name = asset["name"], - name =~ ~r/.sha\d+sum$/, - do: {name, Req.get!(asset["browser_download_url"]).body} - -IO.puts("https://github.com/elixir-lang/elixir/releases/tag/#{tag}") -IO.puts("") - -for {name, checksum} <- Enum.sort(names_and_checksums) do - root = Path.rootname(name) - "." <> type = Path.extname(name) - IO.puts(" * #{root} - #{type} - #{checksum}") -end diff --git a/.github/workflows/notify.exs b/.github/workflows/notify.exs new file mode 100644 index 000000000..6e3efe2e8 --- /dev/null +++ b/.github/workflows/notify.exs @@ -0,0 +1,61 @@ +# #!/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} <- Enum.sort(names_and_checksums) do + 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)}") diff --git a/.github/workflows/notify.yml b/.github/workflows/notify.yml new file mode 100644 index 000000000..58520f3ee --- /dev/null +++ b/.github/workflows/notify.yml @@ -0,0 +1,25 @@ +name: Notify + +on: + release: + types: + - published + +jobs: + notify: + runs-on: ubuntu-latest + name: Notify + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 50 + - uses: erlef/setup-beam@v1 + with: + otp-version: 24.2 + elixir-version: 1.13.1 + - name: Run Elixir script + env: + ELIXIR_FORUM_TOKEN: ${{ secret.ELIXIR_FORUM_TOKEN }} + ELIXIR_LANG_ANN_TOKEN: ${{ secret.ELIXIR_LANG_ANN_TOKEN }} + run: | + elixir .github./workflows/notify.exs ${{ github.ref_name }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 24f2c958a..e4e0c3515 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,5 @@ name: Release + on: push: tags: |