-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathjustfile
95 lines (68 loc) · 2.51 KB
/
justfile
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
# Colors
normal := '\033[0m'
red := '\033[31m'
green := '\033[32m'
yellow := '\033[33m'
# Version settings
git_version := `git rev-parse --short HEAD 2>/dev/null || echo "unknown"`
is_unstable := `git tag --points-at | grep 'v' 2>&1 >/dev/null || echo "-UNSTABLE"`
version := `git cliff --bumped-version 2>/dev/null | cut -c2- || echo "0.0.0"` + is_unstable
version_placeholder := "0.0.0-UNSTABLE"
# Docker settings
registry := "ghcr.io/grampelberg"
image_name := "kty"
tag := "sha-" + git_version
image := registry + "/" + image_name + ":" + tag
tools:
mise install
check: fmt-check lint audit
audit:
cargo audit
fmt-check:
cargo +nightly fmt --all --check
just --fmt --unstable --check
lint:
cargo clippy --no-deps
build-binary:
cargo build --release --bin kty
build-image:
docker build -t {{ image }} -f docker/kty.dockerfile .
tar-bin os arch:
tar -czf kty-{{ version }}-{{ os }}-{{ arch }}.tar.gz -C target/release kty
login-ghcr:
@if [ -z ${GHCR_USER+x} ] || [ -z ${GHCR_TOKEN+x} ]; then \
echo "{{ red }}GHCR_USER and/or GHCR_TOKEN is not set.{{ normal }} See .envrc.example" && exit 1; \
fi
@echo "${GHCR_TOKEN}" | docker login ghcr.io -u "${GHCR_USER}" --password-stdin
upload-image:
docker push {{ image }}
dev-push registry=env_var('LOCAL_REGISTRY'):
just registry="{{ registry }}" tag="latest" build-image upload-image
extract-from-digests:
#!/usr/bin/env bash
set -euo pipefail
mkdir -p /tmp/bins
for digest in /tmp/digests/*/*; do
sha="$(basename "${digest}")"
bucket="$(basename $(dirname "${digest}"))"
IFS=- read -r _ os arch <<< "${bucket}"
name="kty-${os}-${arch}"
echo "Extracting {{ image }}@sha256:${sha}"
container_id="$(docker create --platform=${os}/${arch} {{ image }}@sha256:${sha})"
docker cp "${container_id}:/usr/local/bin/kty" "/tmp/bins/kty"
docker rm "${container_id}"
tar -czf "/tmp/bins/kty-{{ version }}-${os}-${arch}.tar.gz" -C /tmp/bins kty
done
rm /tmp/bins/kty
set-version:
git grep -l "{{ version_placeholder }}" | \
grep -v "justfile" | \
grep -v ".rs" | \
xargs -I {} sed -i'.tmp' -e 's/{{ version_placeholder }}/{{ version }}/g' {}
helm-build:
helm package helm --dependency-update --destination /tmp/chart
helm-upload token="GITHUB_TOKEN":
echo "{{ "${" }}{{ token }}}" | helm registry login {{ registry }} -u gha --password-stdin
helm push /tmp/chart/*.tgz oci://{{ registry }}/helm
docs:
cd docs &&