-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-binaries-matrix
executable file
·122 lines (111 loc) · 2.29 KB
/
build-binaries-matrix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/usr/bin/env ruby
require "json"
RELEASE_NAME = "Binaries"
EXISTING_ASSETS = JSON.parse(`
gh --repo freckle/weeder-action release view #{RELEASE_NAME} --json assets |
jq '.assets | map(.name)'
`)
GHCs = %W[
9.2.5
9.2.4
9.2.3
9.2.2
9.0.2
9.0.1
8.10.7
8.10.6
8.10.5
8.10.4
8.10.3
8.10.2
8.10.1
8.8.4
8.8.3
8.8.2
8.8.1
]
Asset = Struct.new(:ghc, :os) do
def name
"weeder-#{ghc}-#{os}-x64.#{os_attributes.fetch(:ext)}"
end
def include
{ asset: name, ghc: ghc, release: RELEASE_NAME }.
merge(os_attributes).
merge(version_attributes)
end
def os_attributes
case os
when "linux"
{ runner: "ubuntu-latest", ext: "tar.gz", zip: "tar -czf" }
when "darwin"
{ runner: "macOS-latest", ext: "tar.gz", zip: "tar -czf" }
when "win32"
{ runner: "windows-latest", ext: "zip", zip: "zip" }
else
raise "Unexpected OS: #{os}, must be linux|darwin|win32"
end
end
def version_attributes
case ghc
when /9\.2\..*/
{
version: "2.4.0",
resolver: "lts-20.3",
"extra-deps": ""
}
when /9\.0\..*/
{
version: "2.3.1",
resolver: "lts-19.33",
"extra-deps": ""
}
when /8\.10\..*/
{
version: "2.2.0",
resolver: "lts-18.28",
"extra-deps": [
"dhall-1.40.2",
"generic-lens-2.2.1.0",
"generic-lens-core-2.2.1.0"
].join(",")
}
when /8\.8\..*/
{
version: "2.2.0",
resolver: "lts-16.31",
"extra-deps": [
"dhall-1.40.2",
"generic-lens-2.2.1.0",
"generic-lens-core-2.2.1.0",
"base16-bytestring-1.0.2.0",
"prettyprinter-1.7.1",
"repline-0.4.2.0",
"haskeline-0.8.2"
].join(",")
}
end
end
def needed?
!EXISTING_ASSETS.include?(name)
end
end
def generate_matrix
assets = %W[ linux darwin ].
flat_map { |os| GHCs.map { |ghc| Asset.new(ghc, os) } }.
filter(&:needed?)
if assets.empty?
{
asset: ["none"],
include: [{
asset: "none",
runner: "ubuntu-latest"
}]
}
else
{
asset: assets.map(&:name),
include: assets.map(&:include)
}
end
end
puts JSON.dump(generate_matrix)