-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
76 lines (63 loc) · 2.45 KB
/
Copy pathMakefile
File metadata and controls
76 lines (63 loc) · 2.45 KB
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
SHELL := /bin/bash
.PHONY: help build build-release fmt fmt-check clippy test licenses package version-check ci clean
help:
@printf '%-20s %s\n' 'Target' 'Description'
@printf '%-20s %s\n' '------' '-----------'
@printf '%-20s %s\n' 'build' 'Build the debug Rust executable.'
@printf '%-20s %s\n' 'build-release' 'Build the release workflow directory.'
@printf '%-20s %s\n' 'fmt' 'Format Rust source files.'
@printf '%-20s %s\n' 'fmt-check' 'Check Rust formatting.'
@printf '%-20s %s\n' 'clippy' 'Run strict Clippy checks.'
@printf '%-20s %s\n' 'test' 'Run all Rust tests.'
@printf '%-20s %s\n' 'licenses' 'Generate third-party license notices.'
@printf '%-20s %s\n' 'package' 'Create a local .alfredworkflow package.'
@printf '%-20s %s\n' 'version-check' 'Verify Cargo and optional tag versions agree.'
@printf '%-20s %s\n' 'ci' 'Run all local CI checks.'
@printf '%-20s %s\n' 'clean' 'Remove Rust and workflow build output.'
build:
cargo build --locked
build-release:
@set -euo pipefail; \
if [[ -f .env ]]; then \
set -a; \
source .env; \
set +a; \
fi; \
for variable_name in ALGOLIA_APPLICATION_ID ALGOLIA_SEARCH_ONLY_API_KEY ALGOLIA_SEARCH_INDEX; do \
if [[ -z "$${!variable_name:-}" ]]; then \
echo "$$variable_name must be set in the environment or .env file" >&2; \
exit 1; \
fi; \
done; \
cargo build --release --locked
./scripts/package-workflow.sh target/release/alfred_gitmoji
fmt:
cargo fmt --all
fmt-check:
cargo fmt --all --check
clippy:
cargo clippy --all-targets --all-features --locked -- -D warnings
test:
cargo test --all-targets --locked
licenses:
@mkdir -p build
cargo-about generate --locked --fail --output-file build/THIRD_PARTY_LICENSES.html about.hbs
package: build-release
@set -euo pipefail; \
VERSION="$$(awk '/^\[package\]$$/ { p = 1; next } p && /^\[/ { exit } p && /^version = / { gsub(/[\"[:space:]]/, "", $$3); print $$3; exit }' Cargo.toml)"; \
WORKFLOW_NAME="$${WORKFLOW_NAME:-Gitmoji}"; \
ARCHIVE="build/$${WORKFLOW_NAME}-v$${VERSION}.alfredworkflow"; \
TEMP_ARCHIVE="$${ARCHIVE}.tmp.zip"; \
trap 'rm -f "$$TEMP_ARCHIVE"' EXIT; \
rm -f "$$TEMP_ARCHIVE"; \
(cd build/dist && zip -qr "../$${WORKFLOW_NAME}-v$${VERSION}.alfredworkflow.tmp.zip" . \
-x '.env' 'image_cache/*' '*_cache/*' '*_cache_keys.json'); \
mv -f "$$TEMP_ARCHIVE" "$$ARCHIVE"; \
trap - EXIT; \
echo "Created $$ARCHIVE"
version-check:
./scripts/version-check.sh
ci: fmt-check test clippy version-check
clean:
cargo clean
rm -rf build