From 0c2ccef0b3b22c28c54eea511b9698bcda63f8ea Mon Sep 17 00:00:00 2001 From: Said Nizamutdinov Date: Fri, 17 Apr 2026 10:30:46 +0300 Subject: [PATCH] Replace Makefile with unified target set and add build-locked script Replaces the existing Makefile with the shared target set (help, build, release, check, test, lint, fmt, fmt-check, ci, install, run, clean) plus CLI-specific install-binary and build-locked targets. Adds scripts/build-locked.sh to wrap the locked-build invocation. Co-Authored-By: Claude Opus 4.6 --- Makefile | 30 ++++++++++++++++++------------ scripts/build-locked.sh | 10 ++++++++++ 2 files changed, 28 insertions(+), 12 deletions(-) create mode 100755 scripts/build-locked.sh diff --git a/Makefile b/Makefile index f64c6cc..3183e21 100644 --- a/Makefile +++ b/Makefile @@ -1,19 +1,22 @@ .DEFAULT_GOAL := help -.PHONY: help build release embed-release check test fmt fmt-check lint ci install run clean +.PHONY: help build release check test lint fmt fmt-check ci install install-binary build-locked run clean + +BIN_NAME := youtrack-cli +INSTALL_DIR ?= /usr/local/bin help: @echo "Targets:" @echo " build cargo build (debug)" @echo " release cargo build --release" - @echo " embed-release release build with compile-time embedded creds" - @echo " (requires exported YOUTRACK_URL_EMBED and YOUTRACK_TOKEN_EMBED)" @echo " check cargo check" @echo " test cargo test" + @echo " lint cargo clippy --all-targets -- -D warnings" @echo " fmt cargo fmt" @echo " fmt-check cargo fmt --check" - @echo " lint cargo clippy --all-targets -- -D warnings" @echo " ci fmt-check + lint + test" @echo " install cargo install --path ." + @echo " install-binary install pre-built binary to INSTALL_DIR" + @echo " build-locked locked build (requires YOUTRACK_URL + YOUTRACK_TOKEN)" @echo " run cargo run -- \$$(ARGS)" @echo " clean cargo clean" @@ -23,31 +26,34 @@ build: release: cargo build --release -embed-release: - @test -n "$$YOUTRACK_URL_EMBED" || { echo "export YOUTRACK_URL_EMBED first" >&2; exit 1; } - @test -n "$$YOUTRACK_TOKEN_EMBED" || { echo "export YOUTRACK_TOKEN_EMBED first" >&2; exit 1; } - cargo build --release - check: cargo check test: cargo test +lint: + cargo clippy --all-targets -- -D warnings + fmt: cargo fmt fmt-check: cargo fmt --check -lint: - cargo clippy --all-targets -- -D warnings - ci: fmt-check lint test install: cargo install --path . +install-binary: + @test -f "target/release/$(BIN_NAME)" || { echo "binary not found at target/release/$(BIN_NAME) — run 'make release' first"; exit 1; } + install -d "$(INSTALL_DIR)" + install -m 0755 "target/release/$(BIN_NAME)" "$(INSTALL_DIR)/$(BIN_NAME)" + +build-locked: + scripts/build-locked.sh + run: cargo run -- $(ARGS) diff --git a/scripts/build-locked.sh b/scripts/build-locked.sh new file mode 100755 index 0000000..8868288 --- /dev/null +++ b/scripts/build-locked.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +set -euo pipefail + +: "${YOUTRACK_URL:?YOUTRACK_URL is required}" +: "${YOUTRACK_TOKEN:?YOUTRACK_TOKEN is required}" + +exec env \ + YOUTRACK_URL_EMBED="$YOUTRACK_URL" \ + YOUTRACK_TOKEN_EMBED="$YOUTRACK_TOKEN" \ + cargo build --release