# see https://crates.io/crates/cargo-make [env] RUST_TEST_THREADS = "1" CARGO_MAKE_TEST_COVERAGE_BINARY_FILTER = "cli-[a-z0-9]*$\\|makers-[a-z0-9]*$\\|${CARGO_MAKE_TEST_COVERAGE_DEFAULT_BINARY_FILTER}" # TARGET is {arch}-{vendor}-{sys}-{abi} the output of rustc --print target-list TARGET_AUTO = { source = "${CARGO_MAKE_RUST_TARGET_ARCH}-${CARGO_MAKE_RUST_TARGET_VENDOR}-${CARGO_MAKE_RUST_TARGET_OS}-${CARGO_MAKE_RUST_TARGET_ENV}", mapping = { x86_64-apple-macos- = "x86_64-apple-darwin" } } TARGET = { condition = { env_not_set = ["TARGET"] }, value = "${TARGET_AUTO}" } LIBZ_SYS_STATIC = "1" PKG_CONFIG_ALLOW_CROSS = "1" # see https://github.com/naftulikay/rust-openssl-static-example OPENSSL_STATIC = "1" # OPENSSL_LIB_DIR="/usr/lib64" # OPENSSL_INCLUDE_DIR="/usr/include/openssl" CARGO_BUILD_CMD = { source = "${CROSS}", default_value = "cargo", mapping = { true = "cross" } } [tasks.init.mac.env] # workaround for "____chkstk_darwin ... which was built for Mac OS X 10.15 /usr/lib/libSystem.B.dylib" # see https://github.com/sharkdp/bat/issues/680 # if DevelopmentTools.clang_build_version >= 1010 CFLAGS = "-fno-stack-check" #RUSTFLAGS = "-Clink-args=-Wl,-bind_at_load" # XCode --mmacosx-version-min=10.9 ? MACOSX_DEPLOYMENT_TARGET = "10.9" [tasks.dist_env.env] DIST_VERSION = "${CARGO_MAKE_CRATE_VERSION}" DIST_NAME = "${CARGO_MAKE_CRATE_NAME}_${DIST_VERSION}-${TARGET}" DIST_EXT = { source = "${CARGO_MAKE_RUST_TARGET_OS}", default_value = "tgz", mapping = { windows = "zip" } } DIST_PATH = "target/dist/${DIST_NAME}" [tasks.debug] dependencies = ["dist_env"] script_runner = "@duckscript" script = [''' echo "PROFILE=${PROFILE}" echo "MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET}" echo "FILE=${DIST_PATH}.${DIST_EXT}" echo "TARGET=${TARGET}" echo "DIST_VERSION=${DIST_VERSION}" echo "TAG=${TAG}" echo "GITHUB_REF=${GITHUB_REF}" echo "CARGO_BUILD_CMD=${CARGO_BUILD_CMD}" echo ${CARGO_MAKE_PROFILE} : ${DIST_PATH} : ${platform} '''] [tasks.zip-release-ci-flow] description = "Compiles the binary in release mode and zips it up" windows_alias = "zip-release-ci-flow_windows" category = "CI" condition = { env_set = ["TARGET"] } dependencies = [ # "clean", "dist_env", "build-release-for-target", "zip-release-binary-for-target", ] script_runner = "@shell" script = [''' echo "dist_file_path=${DIST_PATH}.${DIST_EXT}" >> $GITHUB_OUTPUT echo "dist_file_name=${DIST_NAME}.${DIST_EXT}" >> $GITHUB_OUTPUT echo "dist_version=${DIST_VERSION}" >> $GITHUB_OUTPUT '''] [tasks.zip-release-ci-flow_windows] description = "Compiles the binary in release mode and zips it up" category = "CI" condition = { env_set = ["TARGET"] } dependencies = [ # "clean", "dist_env", "build-release-for-target", "zip-release-binary-for-target", ] script_runner = "powershell" script_extension = "ps1" script = [''' echo "dist_file_path=${env:DIST_PATH}.${env:DIST_EXT}" >> $env:GITHUB_OUTPUT echo "dist_file_name=${env:DIST_NAME}.${env:DIST_EXT}" >> $env:GITHUB_OUTPUT echo "dist_version=${env:DIST_VERSION}" >> $env:GITHUB_OUTPUT '''] [tasks.setup-cross] description = "Install cross from https://github.com/cross-rs/cross" condition = { env_set = ["TARGET", "CROSS"] } install_crate = { crate_name = "cross", binary = "cross", test_arg = "--help" } [tasks.build-release-for-target] description = "Makes a release build for a given target" condition = { env_set = ["TARGET"] } dependencies = ["setup-cross"] command = "${CARGO_BUILD_CMD}" args = ["build", "--release", "--all-features", "--target", "${TARGET}"] [tasks.zip-release-binary-for-target] windows_alias = "zip-release-binary-for-target_windows" description = "Zips up the release binary, README, and license(s)" category = "Publish" condition = { env_set = ["TARGET"] } # env = { "LIBZ_SYS_STATIC" = "1", "PKG_CONFIG_ALLOW_CROSS" = "1" } script_runner = "@shell" script = [ ''' rm -Rf ${DIST_PATH}* mkdir -p ${DIST_PATH} cp target/${TARGET}/release/${CARGO_MAKE_CRATE_NAME} ${DIST_PATH}/ cp LICENSE* ${DIST_PATH}/ || echo "ignore if no LICENSE" # "cp README* ${DIST_PATH}/ tar -czvf "${DIST_PATH}.${DIST_EXT}" -C "${DIST_PATH}" "${CARGO_MAKE_CRATE_NAME}" ''', ] [tasks.zip-release-binary-for-target_windows] script_runner = "powershell" script_extension = "ps1" script = [ ''' Set-PSDebug -Strict # -Trace 1 $ErrorActionPreference = "Stop" Remove-Item -Recurse -Force "${env:DIST_PATH}" -ErrorAction SilentlyContinue New-Item -ItemType directory -Path "${env:DIST_PATH}" Copy-Item -Path "target\\${env:TARGET}\\release\\${env:CARGO_MAKE_CRATE_NAME}.exe" -Destination "${env:DIST_PATH}" Copy-Item -Path "LICENSE*" -Destination "${env:DIST_PATH}" # Copy-Item -Path "README*" -Destination "${env:DIST_PATH}" Compress-Archive -Path "${env:DIST_PATH}\\*" -DestinationPath "${env:DIST_PATH}.${env:DIST_EXT}" -CompressionLevel Optimal -Force ''', ] [tasks.update-changelog] category = "Publish" install_crate = { crate_name = "gitmoji-changelog", binary = "gitmoji-changelog", test_arg = "--help" } script = [''' rm -Rf CHANGELOG.md gitmoji-changelog -r x.y.z-dev -o CHANGELOG.md . '''] [tasks.install-mdbook] install_crate = { crate_name = "mdbook", binary = "mdbook", test_arg = "--help" } [tasks.install-mdbook-mermaid] install_crate = "mdbook-mermaid" [tasks.install-mdbook-admonish] install_crate = "mdbook-admonish" [tasks.install-mdbook-catppuccin] install_crate = "mdbook-catppuccin" [tasks.update-book] category = "Publish" dependencies = [ "install-mdbook", "install-mdbook-catppuccin", "install-mdbook-admonish", "install-mdbook-mermaid", ] script = [''' cd docs mdbook clean mdbook build '''] [tasks.update-json-schema] category = "Publish" script = [''' cargo run -- show-json-schema > docs/ffizer.schema.json '''] [tasks.pre-publish] dependencies = ["update-docs"] [tasks.update-docs] env = { COMMIT_MSG = ":pencil: pre-publish update book, changelog" } run_task = "_update-docs-do" [tasks._update-docs-do] dependencies = [ "update-book", "update-changelog", "update-json-schema", "git-add", "git-commit-message", ] [tasks.publish] command = "cargo" args = ["release", "${@}"]