-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathJustfile
79 lines (64 loc) · 2.33 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
# Do not exit when variable is unbound (standard is "sh -cu")
set shell := ["sh", "-c"]
vendor_dir := "vendor"
config := ".cargo/config.toml"
target_amd64 := "x86_64-unknown-linux-musl"
target_arm64 := "aarch64-unknown-linux-musl"
default_target := if arch() == "x86_64" {
target_amd64
} else if arch() == "aarch64" {
target_arm64
} else {
error("Unknwon host architecture")
}
# In CI builds we cannot write to the home directory
export CARGO_HOME := if `echo $CI` != "" {
justfile_directory() / ".cargo"
} else {
env("CARGO_HOME", env("HOME") / ".cargo")
}
all: check-licenses test build-amd64 build-arm64 checksum
test:
cargo test --target {{default_target}}
# Debug build for host arch
build:
cargo build --target {{default_target}}
build-amd64: _dist
cargo build --release --target {{target_amd64}}
cp target/{{target_amd64}}/release/picus dist/picus-linux-amd64
build-arm64: _dist
cargo build --release --target {{target_arm64}}
cp target/{{target_arm64}}/release/picus dist/picus-linux-arm64
checksum: _dist
cd dist; sha256sum * > sha256sum.txt
_dist:
mkdir -p dist
check-licenses:
cargo install cargo-deny
cargo deny check licenses
# Vendor sources and create source archive
vendor: _dist
#!/bin/sh -e
cargo vendor {{vendor_dir}}
if ! grep vendored-sources {{config}}; then
echo '\n[source.crates-io]\nreplace-with = "vendored-sources"\n\n[source.vendored-sources]\ndirectory = "{{vendor_dir}}"' >> {{config}};
fi
if [ -n "$CI_COMMIT_TAG" ]; then
# remove the leading 'v' from the tag
VERSION=$(expr substr "$CI_COMMIT_TAG" 2 100)
SOURCE_ARCHIVE=dist/picus-vendored-source-${VERSION}.tar.gz
SOURCE_ARCHIVE_BASE=picus-${VERSION}
else
SOURCE_ARCHIVE=dist/picus-vendored-source.tar.gz
SOURCE_ARCHIVE_BASE=picus
fi
# Note: The order is important in the next line. --exclude only affects
# items mentioned after it. So we can include .cargo/config.toml
# while excluding the rest of the folder.
tar -czf ${SOURCE_ARCHIVE} --transform "s,^,${SOURCE_ARCHIVE_BASE}/," .cargo/config.toml --exclude=.cargo --exclude=target --exclude=dist --exclude=.git .
clean:
rm -rf target
rm -rf {{vendor_dir}}
# Revert changes for vendored sources
git checkout -- {{config}}
rm -rf dist