blob: fe2b0b06209613b5b8fdccf0def989d97b6e7378 (
plain)
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
|
TEMPDIR := `mktemp -d`
TEMPFILE := `mktemp`
BUILDDIR := "_build"
ALL_VERSIONS := BUILDDIR / "ALL_VERSIONS"
NEW_VERSION := BUILDDIR / "NEW_VERSION"
CURRENT_VERSION := BUILDDIR / "CURRENT_VERSION"
COMMIT := `git rev-parse --short HEAD`
TAGS := `git tag -l`
default:
@just --choose
docker-build part="latest": (new-ver part)
#!/usr/bin/env bash
set -euo pipefail
new_ver=$(cat {{ NEW_VERSION }}); \
docker build --build-arg="version=$new_ver" -t unbound-ads:$new_ver .
builddir:
mkdir -p {{ BUILDDIR }}/etc
mkdir -p {{ BUILDDIR }}/bin
clean:
rm -r {{ BUILDDIR }}
new-ver part="latest": builddir
#!/usr/bin/env bash
set -euo pipefail
echo {{part}}
echo "{{ TAGS }}" > {{ ALL_VERSIONS }}
cat {{ ALL_VERSIONS }} | bumpver --last-version patch - > {{ CURRENT_VERSION }}
if [[ {{part}} == "latest" ]];
then
bumpver patch --prerelease --prerelease-fmt 'latest.$KeyArg commit.$BumpInt' -k commit={{COMMIT}} {{ CURRENT_VERSION }} > {{ NEW_VERSION }}
git tag $(cat {{ NEW_VERSION }})
else
bumpver {{part}} <(git tag -l) > {{ NEW_VERSION }}
fi
git-push tag:
new_ver=$(cat {{ NEW_VERSION }}); \
git push origin master; \
git push origin {{ tag }}
git-build-release:
#!/usr/bin/env bash
set -euo pipefail
new_ver=$(cat {{ NEW_VERSION }})
current_ver=$(cat {{ CURRENT_VERSION}})
# temp light weight tag for building release notes
git tag $new_ver
echo "v${new_ver} release" > {{ TEMPDIR }}/chglog
git-chglog $current_ver..$new_ver >> {{ TEMPDIR }}/chglog
echo "## Coverage" >> {{ TEMPDIR }}/chglog
echo "" >> {{ TEMPDIR }}/chglog
go tool cover -func={{ TEMPDIR }}/testcover.out >> {{ TEMPDIR }}/chglog
# end temp tag
git tag -d $new_ver
git-tag-release:
new_ver=$(cat {{ NEW_VERSION }}); \
git tag --annotate --sign --cleanup=whitespace --file {{ TEMPDIR }}/chglog ${new_ver}
git-tag-clean:
#!/usr/bin/env bash
set -euo pipefail
for tag in $(git tag -l "*-latest.*.*");
do
git tag -d $tag;
done
# Release project, create new tags, build container, and push
release part: test builddir (docker-build part) git-build-release git-tag-release push
new_ver=$(cat {{ NEW_VERSION }}); \
@echo "Version $new_ver has been released!"
build version: test builddir
CGO_ENABLED=0 go build -a -ldflags "-s -X 'main.Version={{version}}'" -o {{ BUILDDIR }}/bin/unbound-ads main.go
local-build: new-ver
new_ver=$(cat {{ NEW_VERSION }}); \
just build $new_ver
push:
just docker-push; \
just git-push
@echo "pushed to all endpoints"
docker-push registry="public.ecr.aws/s0f9o2k5":
#!/usr/bin/env bash
set -euo pipefail
new_ver=$(cat {{ NEW_VERSION }})
docker tag unbound-ads:$new_ver {{registry}}/unbound-ads:$new_ver
docker push {{registry}}/unbound-ads:$new_ver
if [[ $new_ver != *"latest"* ]];
then
docker tag unbound-ads:$new_ver {{registry}}/unbound-ads:latest
docker push {{registry}}/unbound-ads:latest
fi
run url="https://v.firebog.net/hosts/lists.php?type=tick" output=(TEMPFILE):
go run main.go {{url}} {{output}}
echo "{{output}}"
test:
golangci-lint run
go test -v -coverprofile={{ TEMPDIR }}/testcover.out ./...
go tool cover -func={{ TEMPDIR }}/testcover.out
|