-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
86 lines (82 loc) · 1.99 KB
/
justfile
File metadata and controls
86 lines (82 loc) · 1.99 KB
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
set shell := ["bash","-euxo","pipefail"]
release_dir := "release"
package_path := "github.com/docker/docker-credential-helpers"
helpers_darwin := "osxkeychain pass plain"
helpers_linux := "pass secretservice plain"
archs := "amd64 arm64"
build-release:
#!/bin/bash
rm -rf {{release_dir}}
mkdir -p {{release_dir}}
for os in darwin linux; do
helpers="{{helpers_darwin}}"
if [ "$os" = "linux" ]; then
helpers="{{helpers_linux}}"
fi
for arch in {{archs}}; do
for helper in $helpers; do
bin="docker-credential-$helper"
out={{release_dir}}/${bin}_${os}_${arch}
GOOS="$os" GOARCH="$arch" go build -trimpath -ldflags "-s -w -X {{package_path}}/credentials.Name=$bin" -o "$out" "./$helper/cmd/"
done
done
done
default: build-release
publish-release: build-release
#!/bin/bash
if ! command -v gh >/dev/null; then
echo "gh CLI must be installed to publish a release"
exit 1
fi
gh_token="${GH_TOKEN:-}"
if [ -z "$gh_token" ] && [ -f "$HOME/.netrc" ]; then
gh_token=$(
awk '
{
for (i = 1; i <= NF; i++) {
tok = $i
if (tok == "machine") {
state = "machine"
continue
}
if (tok == "login") {
state = "login"
continue
}
if (tok == "password") {
state = "password"
continue
}
if (state == "machine") {
machine = tok
state = ""
continue
}
if (state == "password") {
if (machine == "github.com") {
print tok
exit
}
state = ""
continue
}
}
}
' "$HOME/.netrc"
)
fi
if [ -n "$gh_token" ]; then
export GH_TOKEN="$gh_token"
fi
latest_tag=$(git describe --tags --abbrev=0)
if [ -z "$latest_tag" ]; then
echo "no git tags available to release"
exit 1
fi
assets=({{release_dir}}/*)
if [ "${#assets[@]}" -eq 0 ]; then
echo "no binaries found in {{release_dir}}; run just build-release first"
exit 1
fi
gh repo set-default
gh release create "$latest_tag" --title "$latest_tag" --notes "Release $latest_tag binaries" "${assets[@]}"