docker_image_name := "swift-hpa" install_path := "~/.local/share/bin/hpa" completion_path := "~/.local/share/zsh/completions/_hpa" tap_url := "https://git.housh.dev/michael/homebrew-formula" tap := "michael/formula" formula := "hpa" release_base_url := "https://git.housh.dev/michael/swift-hpa/archive" # Build and bottle homebrew formula. bottle: @brew uninstall {{formula}} || true @brew tap {{tap}} {{tap_url}} @brew install --build-bottle {{tap}}/{{formula}} @brew bottle {{formula}} bottle="$(ls *.gz)" && mv "${bottle}" "${bottle/--/-}" # Build the command-line tool. build configuration="debug" arch="arm64": swift build \ --disable-sandbox \ --configuration {{configuration}} \ --arch {{arch}} alias b := build # Build the docker image. build-docker file="Dockerfile" tag="latest": @docker build \ --file docker/{{file}} \ --tag {{docker_image_name}}:{{tag}} . # Build the docker test image used for testing. build-docker-test: (build-docker "Dockerfile.test" "test") build-universal-binary: (build "release" "arm64") (build "release" "x86_64") @lipo -create -output {{formula}} \ ".build/arm64-apple-macosx/release/hpa" \ ".build/x86_64-apple-macosx/release/hpa" # Run tests. test *ARGS: swift test {{ARGS}} alias t := test # Run tests in docker container. test-docker *ARGS: (build-docker-test) @docker run --rm \ --network host \ {{docker_image_name}}:test \ swift test {{ARGS}} # Remove bottles remove-bottles: rm -rf *.gz # Run the application. run *ARGS: swift run hpa {{ARGS}} alias r := run # Clean the build folder. clean: rm -rf .build # Bump the version based on the git tag. update-version: @swift package \ --disable-sandbox \ --allow-writing-to-package-directory \ update-version \ hpa # Get the sha256 sum of the release and copy to clipboard. get-release-sha prefix="": (build "release") version=$(.build/release/hpa --version) && \ url="{{release_base_url}}/{{prefix}}${version}.tar.gz" && \ sha=$(curl "$url" | shasum -a 256) && \ stripped="${sha% *}" && \ echo "$stripped" | pbcopy && \ echo "Copied sha to clipboard: $stripped"