cargo-make 0.37.24

Rust task runner and build tool.
Documentation

[tasks.github-publish]
# Creates a new github release.
# Set the GITHUB_API_TOKEN environment variables to automatically authenticate.
description = "Creates a new github release."
category = "Publish"
command = "cargo"
args = ["hublish"]

[tasks.github-publish-custom-name]
# Creates a new github release.
# Set the GITHUB_API_TOKEN environment variables to automatically authenticate.
description = "Creates a new github release."
category = "Publish"
dependencies = ["github-hub-find"]
condition = { env = { "CARGO_MAKE_GIT_BRANCH" = "master" } }
run_task = [
  { name = "github-publish-hub", condition = { env_set = [
    "GITHUB_API_TOKEN",
  ], env_true = [
    "CARGO_MAKE_GITHUB_HUB_CLI_FOUND",
  ] } },
  { name = "github-publish-curl", condition = { platforms = [
    "linux",
    "mac",
  ], env_set = [
    "GITHUB_API_TOKEN",
    "GITHUB_REPO_NAME",
  ] } },
  { name = "github-publish-hublish", condition = { env_set = [
    "GITHUB_REPO_NAME",
  ] } },
]

[tasks.github-hub-find]
description = "Sets the CARGO_MAKE_GITHUB_HUB_CLI_FOUND environment variable with the current hub executable location (if found)."
category = "Tools"
script = '''
#!@duckscript
exit_on_error false

output = exec hub --help
exit_code = set ${output.code}
valid = equals ${exit_code} 0

if ${valid}
    echo GitHub hub cli found
    set_env CARGO_MAKE_GITHUB_HUB_CLI_FOUND true
end
'''

[tasks.github-publish-hub]
# Creates a new github release.
description = "Creates a new github release using hub."
category = "Publish"
condition = { env_set = [
  "GITHUB_API_TOKEN",
  "CARGO_MAKE_PROJECT_NAME",
  "CARGO_MAKE_PROJECT_VERSION",
] }
env = { "GITHUB_TOKEN" = "${GITHUB_API_TOKEN}" }
command = "hub"
args = [
  "release",
  "create",
  "-m",
  "${CARGO_MAKE_PROJECT_NAME} v${CARGO_MAKE_PROJECT_VERSION}",
  "${CARGO_MAKE_PROJECT_VERSION}",
]

[tasks.github-publish-hublish]
# Creates a new github release.
# Set the GITHUB_API_TOKEN environment variables to automatically authenticate.
description = "Creates a new github release using cargo-hublish."
category = "Publish"
condition = { env_set = ["GITHUB_REPO_NAME"] }
install_crate = "cargo-hublish"
args = ["hublish"]
script_runner = "@shell"
script = '''
cargo hublish --url "https://api.github.com/repos/${GITHUB_REPO_NAME}/releases"
'''

[tasks.github-publish-curl]
# Creates a new github release.
description = "Creates a new github release using curl."
category = "Publish"
condition = { platforms = [
  "linux",
  "mac",
], env_set = [
  "GITHUB_API_TOKEN",
  "GITHUB_REPO_NAME",
  "CARGO_MAKE_PROJECT_NAME",
  "CARGO_MAKE_PROJECT_VERSION",
] }
script = '''
API_JSON=$(printf '{"tag_name": "%s","target_commitish": "master","name": "%s v%s","body": "release","draft": false,"prerelease": false}' ${CARGO_MAKE_PROJECT_VERSION} ${CARGO_MAKE_PROJECT_NAME} ${CARGO_MAKE_PROJECT_VERSION})
curl --data "$API_JSON" -H "Authorization: token ${GITHUB_API_TOKEN}" https://api.github.com/repos/${GITHUB_REPO_NAME}/releases
'''