@@ -6,17 +6,17 @@ Mix.install([
6
6
{ :jason , "~> 1.0" }
7
7
] )
8
8
9
- % { status: 200 , body: body } =
9
+ % { status: 200 , body: release } =
10
10
Req . get! ( "https://api.github.com/repos/elixir-lang/elixir/releases/tags/#{ tag } " )
11
11
12
- if body [ "draft" ] do
12
+ if release [ "draft" ] do
13
13
raise "cannot notify a draft release"
14
14
end
15
15
16
16
## Notify on elixir-lang-ann
17
17
18
18
names_and_checksums =
19
- for asset <- body [ "assets" ] ,
19
+ for asset <- release [ "assets" ] ,
20
20
name = asset [ "name" ] ,
21
21
name =~ ~r/ .sha\d +sum$/ ,
22
22
do: { name , Req . get! ( asset [ "browser_download_url" ] ) . body }
@@ -29,34 +29,44 @@ line_items =
29
29
" * #{ root } - #{ type } - #{ checksum } \n "
30
30
end
31
31
32
- headers = % {
33
- "X-Postmark-Server-Token" => System . fetch_env! ( "ELIXIR_LANG_ANN_TOKEN" )
34
- }
35
-
36
- body = % {
32
+ mail = % {
37
33
38
34
39
35
"Subject" => "Elixir #{ tag } released" ,
40
36
"HtmlBody" => "https://github.com/elixir-lang/elixir/releases/tag/#{ tag } \n \n #{ line_items } " ,
41
- "MessageStream": "outbound"
37
+ "MessageStream" => "outbound"
42
38
}
43
39
44
- resp = Req . post! ( "https://api.postmarkapp.com/email" , { :json , body } , headers: headers )
45
- IO . puts ( "#{ resp . status } elixir-lang-ann\n #{ inspect ( resp . body ) } " )
40
+ if System . get_env ( "DRYRUN" ) do
41
+ IO . puts ( "MAIL" )
42
+ IO . inspect ( mail )
43
+ else
44
+ headers = % {
45
+ "X-Postmark-Server-Token" => System . fetch_env! ( "ELIXIR_LANG_ANN_TOKEN" )
46
+ }
46
47
47
- ## Notify on Elixir Forum
48
+ resp = Req . post! ( "https://api.postmarkapp.com/email" , { :json , mail } , headers: headers )
49
+ IO . puts ( "#{ resp . status } elixir-lang-ann\n #{ inspect ( resp . body ) } " )
50
+ end
48
51
49
- headers = % {
50
- "api-key" => System . fetch_env! ( "ELIXIR_FORUM_TOKEN" ) ,
51
- "api-username" => "Elixir"
52
- }
52
+ ## Notify on Elixir Forum
53
53
54
- body = % {
54
+ post = % {
55
55
"title" => "Elixir #{ tag } released" ,
56
- "raw" => "https://github.com/elixir-lang/elixir/releases/tag/#{ tag } \n \n #{ body [ "body" ] } " ,
56
+ "raw" => "https://github.com/elixir-lang/elixir/releases/tag/#{ tag } \n \n #{ release [ "body" ] } " ,
57
57
# Elixir News
58
58
"category" => 28
59
59
}
60
60
61
- resp = Req . post! ( "https://elixirforum.com/posts.json" , { :json , body } , headers: headers )
62
- IO . puts ( "#{ resp . status } Elixir Forum\n #{ inspect ( resp . body ) } " )
61
+ if System . get_env ( "DRYRUN" ) do
62
+ IO . puts ( "POST" )
63
+ IO . inspect ( post )
64
+ else
65
+ headers = % {
66
+ "api-key" => System . fetch_env! ( "ELIXIR_FORUM_TOKEN" ) ,
67
+ "api-username" => "Elixir"
68
+ }
69
+
70
+ resp = Req . post! ( "https://elixirforum.com/posts.json" , { :json , post } , headers: headers )
71
+ IO . puts ( "#{ resp . status } Elixir Forum\n #{ inspect ( resp . body ) } " )
72
+ end
0 commit comments