# ---- Profiles ---- [env] BUILD_DIR = "target/" LIB_NAME = "${CARGO_MAKE_CRATE_NAME}" BIN_NAME = "${CARGO_MAKE_CRATE_FS_NAME}" BIN_VERSION = "${CARGO_MAKE_CRATE_VERSION}" BUILD_ARGS = "--target-dir ${BUILD_DIR}" DOCKER_BUILD_IMAGE = "proctorlabs/rust-builder" OUTPUT_DIR = "${BUILD_DIR}/debug/" PACKAGE_DIR = "target/packages/" RUST_CHANNEL = "beta" RUST_TARGET = "x86_64-unknown-linux-gnu" RUSTUP_TOOLCHAIN = "${RUST_CHANNEL}-x86_64-unknown-linux-gnu" [env.libc] BUILD_TAR = true BUILD_DEB = true PUBLISH_CRATE = true PACKAGE_SUFFIX = "amd64-libc" PACKAGE_BASENAME = "${BIN_NAME}-${BIN_VERSION}-${PACKAGE_SUFFIX}" BUILD_ARGS = "--target ${RUST_TARGET} --release" OUTPUT_DIR = "${BUILD_DIR}/${RUST_TARGET}/release/" [env.musl] BUILD_TAR = true BUILD_DEB = true PUBLISH_CRATE = false RUST_TARGET = "x86_64-unknown-linux-musl" PACKAGE_SUFFIX = "amd64-musl" PACKAGE_BASENAME = "${BIN_NAME}-${BIN_VERSION}-${PACKAGE_SUFFIX}" BUILD_ARGS = "--target ${RUST_TARGET} --release" OUTPUT_DIR = "${BUILD_DIR}/${RUST_TARGET}/release/" [config] toolchain = "beta" [tasks.init] install_script = [ "rustup toolchain install ${RUST_CHANNEL}", "rustup default ${RUST_CHANNEL}", "rustup target add ${RUST_TARGET}" ] # ---- Development ---- [tasks.build] description = "Build project" command = "cargo" args = ["build", "--all-targets", "@@split(BUILD_ARGS, )"] [tasks.run] description = "Run project" command = "cargo" args = ["run", "@@split(BUILD_ARGS, )", "--", "-c", "demo/demo.yml", "${@}"] [tasks.in-docker] description = "Run this cargo make command in docker" script = ["docker run --rm -it -u $UID:$UID -v $PWD:/src -v ~/.cargo/credentials:/src/.cargo/credentials:ro -w /src ${DOCKER_BUILD_IMAGE} cargo make --disable-check-for-updates ${@}"] [tasks.readme-dep-install] install_crate = "cargo-readme" command = "cargo" args = ["readme", "-o", "/dev/null"] private = true [tasks.readme] description = "Update documentation" script = [] dependencies = ["readme-dep-install"] [tasks.validate] description = "Ensure project is cleaned up and has no warnings" install_crate = { rustup_component_name = "rustfmt" } script = [ "cargo test --all-features", "cargo build --no-default-features" ] dependencies = ["verify-project", "format", "check", "clippy", "build", "test"] # ---- Install from source ---- [tasks.install] description = "Install locally from source" script = ["cargo install --bins --path ."] dependencies = ["build"] [tasks.uninstall] description = "Delete local install" script = ["cargo uninstall"] # ---- Packaging ---- [tasks.package-deb] condition = { env_true = ["BUILD_DEB"] } description = "Create debian package" install_crate = "cargo-deb" command = "cargo" args = ["deb", "--target", "${RUST_TARGET}", "--no-build", "-o", "${PACKAGE_DIR}${PACKAGE_BASENAME}.deb"] dependencies = ["build"] [tasks.package-tar] condition = { env_true = ["BUILD_TAR"] } description = "Create tar package" script = [ ''' #!/usr/bin/env bash pushd ${OUTPUT_DIR} strip ${BIN_NAME} tar -cvJf ${PACKAGE_BASENAME}.tar.xz ${BIN_NAME} popd mkdir -p ${PACKAGE_DIR} mv ${OUTPUT_DIR}${PACKAGE_BASENAME}.tar.xz ${PACKAGE_DIR} ''' ] shell = "bash" dependencies = ["build"] [tasks.packages] description = "Create all packages" dependencies = ["package-tar", "package-deb"] # ---- Release Management ---- [tasks.validate-release] description = "Verify and push tag for new release" script = [ ''' #!/usr/bin/env bash set -Eeou pipefail if [[ $(git diff --stat) != '' ]]; then echo 'Working tree dirty, aborting' exit 1 fi ''' ] dependencies = ["validate"] [tasks.publish-crate] condition = { env_true = ["PUBLISH_CRATE"] } description = "Publish crate" command = "cargo" args = ["publish", "--all-features", "--token", "${CRATE_KEY}"] dependencies = ["validate-release"] [tasks.mark-release] description = "Verify and push tag for new release" script = [ ''' #!/usr/bin/env bash set -Eeou pipefail git tag v${BIN_VERSION} git push origin refs/tags/v${BIN_VERSION} ''' ] dependencies = ["validate-release"] [tasks.do-release] description = "Complete release flow" dependencies = ["validate-release", "packages", "publish-crate"]