-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
61 lines (50 loc) · 2.02 KB
/
Makefile
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
CONTAINER_RUNTIME ?= docker
CONTAINER_IMAGE := "ghcr.io/kubewarden/swift-wasm-runner:5.3-p1"
# It's necessary to call cut because kwctl command does not handle version
# starting with v.
VERSION ?= $(shell git describe | cut -c2-)
build:
ifndef CONTAINER_RUNTIME
@printf "Please install either docker or podman"
exit 1
endif
$(CONTAINER_RUNTIME) run --rm -v $(PWD):/code --entrypoint /bin/bash $(CONTAINER_IMAGE) -c "cd /code && swift build --triple wasm32-unknown-wasi"
shell:
ifndef CONTAINER_RUNTIME
@printf "Please install either docker or podman"
exit 1
endif
$(CONTAINER_RUNTIME) run --rm -ti -v $(PWD):/code --entrypoint /bin/bash $(CONTAINER_IMAGE)
test:
ifndef CONTAINER_RUNTIME
@printf "Please install either docker or podman"
exit 1
endif
$(CONTAINER_RUNTIME) run --rm -v $(PWD):/code --entrypoint /bin/bash $(CONTAINER_IMAGE) -c "cd /code && carton test"
clean:
sudo rm -rf .build
rm -rf *.wasm
release:
ifndef CONTAINER_RUNTIME
@printf "Please install either docker or podman"
exit 1
endif
@printf "Build WebAssembly module"
$(CONTAINER_RUNTIME) run --rm -v $(PWD):/code --entrypoint /bin/bash $(CONTAINER_IMAGE) -c "cd /code && swift build -c release --triple wasm32-unknown-wasi"
@printf "Strip Wasm binary\n"
sudo chmod 777 .build/wasm32-unknown-wasi/release/Policy.wasm
wasm-strip .build/wasm32-unknown-wasi/release/Policy.wasm
@printf "Optimize Wasm binary, hold on...\n"
wasm-opt -Os .build/wasm32-unknown-wasi/release/Policy.wasm -o policy.wasm
artifacthub-pkg.yml: metadata.yml
$(warning If you are updating the artifacthub-pkg.yml file for a release, \
remember to set the VERSION variable with the proper value. \
To use the latest tag, use the following command: \
make VERSION=$$(git describe --tags --abbrev=0 | cut -c2-) annotated-policy.wasm)
kwctl scaffold artifacthub \
--metadata-path metadata.yml --version $(VERSION) \
--output artifacthub-pkg.yml
annotate: artifacthub-pkg.yml
kwctl annotate -m metadata.yml -u README.md -o annotated-policy.wasm policy.wasm
e2e-tests:
bats e2e.bats