]> git.r.bdr.sh - rbdr/blog/blame - Makefile
Add an actual remote check to git.
[rbdr/blog] / Makefile
CommitLineData
a04ba49c
RBR
1profile := dev
2target = $(shell rustc -vV | grep host | awk '{print $$2}')
3architectures := x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu
43780806 4app_name := blog
d620665f
RBR
5
6default: build
7
5c7a9258
RBR
8set_rust:
9 rustup default stable
10
a04ba49c
RBR
11prepare:
12 rustup target add $(target)
d620665f 13
a04ba49c
RBR
14build: prepare
15 cargo build --profile $(profile) --target $(target)
16
d7fef30a
RBR
17test:
18 cargo test
19
20coverage:
21 cargo tarpaulin
22
23format:
24 cargo fmt && cargo clippy --fix
25
26lint:
27 cargo fmt -- --check && cargo clippy
28
7c6c129b 29release: rpm tar deb
4dfd8d3d 30 @$(eval filename := $(app_name)-$(target)-$(channel))
c4b892b1 31
a04ba49c 32$(architectures):
c4b892b1
RBR
33ifneq ($(channel),)
34 $(MAKE) -e channel=$(channel) -e target=$@ release
43780806
RBR
35else
36 $(MAKE) -e target=$@ build
c4b892b1 37endif
a04ba49c 38
94b6e2ec 39deb: build
d26464d1 40ifeq ($(findstring linux,$(target)),linux)
94b6e2ec
RBR
41 @$(eval filename := $(app_name)-$(target)-$(channel))
42 cargo deb --profile $(profile) --target $(target)
7c6c129b 43 mv target/$(target)/debian/*.deb $(filename).deb
94b6e2ec
RBR
44 sha256sum $(filename).deb > $(filename).deb.sha256
45 rsync -avz $(filename).deb deploy@conchos.unlimited.pizza:/srv/http/build.r.bdr.sh/$(app_name)
46 rsync -avz $(filename).deb.sha256 deploy@conchos.unlimited.pizza:/srv/http/build.r.bdr.sh/$(app_name)
d26464d1 47endif
94b6e2ec 48
a04ba49c 49rpm: build
d26464d1 50ifeq ($(findstring linux,$(target)),linux)
6b85c7c4
RBR
51 @$(eval filename := $(app_name)-$(target)-$(channel))
52 cargo generate-rpm --profile $(profile) --target $(target)
53 mv target/$(target)/generate-rpm/*.rpm $(filename).rpm
54 sha256sum $(filename).rpm > $(filename).rpm.sha256
55 rsync -avz $(filename).rpm deploy@conchos.unlimited.pizza:/srv/http/build.r.bdr.sh/$(app_name)
56 rsync -avz $(filename).rpm.sha256 deploy@conchos.unlimited.pizza:/srv/http/build.r.bdr.sh/$(app_name)
d26464d1 57endif
a04ba49c 58
43780806 59tar: build
4dfd8d3d
RBR
60 @$(eval filename := $(app_name)-$(target)-$(channel))
61 tar -czvf $(filename).tar.gz -C target/$(target)/$(profile)/ $(app_name)
6b85c7c4 62 sha256sum $(filename).tar.gz > $(filename).tar.gz.sha256
27c166eb 63 rsync -avz $(filename).tar.gz deploy@conchos.unlimited.pizza:/srv/http/build.r.bdr.sh/$(app_name)
6b85c7c4 64 rsync -avz $(filename).tar.gz.sha256 deploy@conchos.unlimited.pizza:/srv/http/build.r.bdr.sh/$(app_name)
43780806 65
a04ba49c
RBR
66package: $(architectures)
67
d26464d1
RBR
68mac:
69 @$(eval mac_architectures := x86_64-apple-darwin aarch64-apple-darwin)
70ifeq ($(tag),)
71 $(MAKE) -e profile=release -e architectures='$(mac_architectures)' -e channel=unstable package
72else
73 $(MAKE) -e profile=release -e architectures='$(mac_architectures)' -e channel=$(tag) package
74endif
75
d7fef30a 76ci: lint coverage
c4b892b1 77ifeq ($(GIT_REF),refs/heads/main)
b12f5ad8 78 $(MAKE) -e profile=release -e channel=unstable package
c4b892b1 79else ifneq (,$(findstring refs/tags/,$(GIT_REF)))
b12f5ad8 80 $(MAKE) -e profile=release -e channel=$(subst refs/tags/,,$(GIT_REF)) package
c4b892b1
RBR
81endif
82
83.PHONY: default build $(architectures) rpm package prepare set_rust ci release