-
Notifications
You must be signed in to change notification settings - Fork 130
/
github.toml
100 lines (92 loc) · 2.9 KB
/
github.toml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
[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
'''