-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathbrew-update
executable file
·71 lines (58 loc) · 2.03 KB
/
brew-update
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
#!/usr/bin/env ys-0
releases-url =: 'https://github.com/yaml/yamlscript/releases'
brew-url =: '[email protected]:yaml/homebrew-yamlscript'
defn main(version):
check-version: version
download-releases: version
update-brew: version
defn update-brew(version):
releases =: releases(version)
when-not fs-e('homebrew-yamlscript'):
say: "Cloning $brew-url"
res =: sh("git clone $brew-url")
when res.exit:N.?:
die: "git clone of '$brew-url' failed\n$(res.err)"
text =: read('homebrew-yamlscript/template/ys.rb')
.replace('VERSION' version)
text =:
reduce-kv _ text releases:
fn(text key file):
sha256 =: sh("sha256sum $file").out:words.0
text: .replace(key sha256)
say: "Updating homebrew-yamlscript/ys.rb"
write 'homebrew-yamlscript/ys.rb':
text.replace('CLASS' 'Ys')
vrsn =: version.replace('.')
say: "Updating homebrew-yamlscript/[email protected]"
write "homebrew-yamlscript/ys@$version.rb":
text.replace('CLASS' "YsAT$vrsn")
say: "Updating homebrew-yamlscript/ReadMe.md"
write "homebrew-yamlscript/ReadMe.md":
read("homebrew-yamlscript/template/ReadMe.md")
.replace('VERSION' version)
status =: sh('git -C homebrew-yamlscript status --short --ignored').out
if status.?:
say: status
say: "Nothing changed"
defn download-releases(version):
releases =: releases(version)
reduce-kv _ nil releases:
fn(_ _ file):
when-not fs-e(file):
say: "Downloading $file"
url =: "$releases-url/download/$version/$file"
res =: sh("wget -q $url")
when res.exit:N.?:
die: "Download of '$url' failed:\n$(res.err)"
defn releases(version)::
LIN_ARM:: "ys-${version}-linux-aarch64.tar.xz"
LIN_INT:: "ys-${version}-linux-x64.tar.xz"
MAC_ARM:: "ys-${version}-macos-aarch64.tar.xz"
MAC_INT:: "ys-${version}-macos-x64.tar.xz"
defn check-version(version):
when version !~ /^0\.1\.\d+$/:
die: "Invalid version '$version'"
try:
curl: "$releases-url/tag/$version"
catch:
die: "No YS release for version '$version'"