diff --git a/.gitignore b/.gitignore index 6f4f22e..8ab3131 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ DerivedData/ .swiftpm/* ./hpa.toml ./Version.* +/*.json diff --git a/justfile b/justfile index c7e7e86..39a7002 100644 --- a/justfile +++ b/justfile @@ -2,44 +2,60 @@ 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" + +# Build and bottle homebrew formula. +bottle: + @brew uninstall {{formula}} || true + @brew tap {{tap}} {{tap_url}} + @brew install --build-bottle {{formula}} + @brew bottle {{formula}} --json + bottle="$(ls *.gz)" && mv "${bottle}" "${bottle/--/-}" + +# Build the command-line tool. build mode="debug": swift build -c {{mode}} 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") +# 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}} +# 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 - -install: (build "release") - @cp .build/release/hpa {{install_path}} - @{{install_path}} --generate-completion-script zsh > {{completion_path}}