Skip to content

Commit

Permalink
FIX!: Updated common tasks & fixed dist tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
MrDwarf7 committed Jan 20, 2025
1 parent c27e595 commit 8a19ae1
Show file tree
Hide file tree
Showing 3 changed files with 223 additions and 112 deletions.
194 changes: 103 additions & 91 deletions build/common-tasks.toml
Original file line number Diff line number Diff line change
@@ -1,91 +1,103 @@
[env]
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true
CARGO_MAKE_TIME_SUMMARY = true
BREAKER = "----------------------------------------"

ROOT = "${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}"

#PROFILE = "${CARGO_MAKE_CARGO_PROFILE}"
PROFILE = "release"
VERSION = "${CARGO_MAKE_PROJECT_VERSION}"
# Name of the output binary
BIN_NAME = "${CARGO_MAKE_PROJECT_NAME}"
# The formatted name of the output binary we want
OUTPUT_BIN_NAME = "${BIN_NAME}_${VERSION}"
# The folder where the binary will be copied to -- /_output_bin_name_dist
DIST_FOLDER = "${ROOT}/_${OUTPUT_BIN_NAME}_dist"
# the FULL path from root WITH EXE - root / target /current_profile / the_bin_name.EXE
FOLDER_BIN_EXE = "${ROOT}/target/${PROFILE}/${BIN_NAME}.exe"

[tasks.print_all]
command = "@duckscript"
script = '''@duckscript
echo "ROOT: ${ROOT}"
echo "PROFILE: ${PROFILE}"
echo "VERSION: ${VERSION}"
echo "BIN_NAME: ${BIN_NAME}"
echo "OUTPUT_BIN_NAME: ${OUTPUT_BIN_NAME}"
echo "DIST_FOLDER: ${DIST_FOLDER}"
echo "FOLDER_BIN_EXE: ${FOLDER_BIN_EXE}"
echo "BREAKER: ${BREAKER}"
'''

# START Core bare. min
[tasks.format]
command = "cargo"
args = ["fmt", "--", "--emit=files"]

[tasks.clean]
command = "cargo"
args = ["clean"]

[tasks.build]
command = "cargo"
args = ["build"]
dependencies = ["format"]

[tasks.build_release]
command = "cargo"
args = ["build", "--release"]
dependencies = ["format"]

[tasks.docs]
command = "cargo"
args = ["doc", "--no-deps"]
# END Core bare. min

# START Tests
[tasks.test]
command = "cargo"
args = ["test"]

[tasks.test_all]
command = "cargo"
args = ["test", "--all"]
# END Tests

# START Function outputs
[tasks.run]
command = "cargo"
args = ["run"]

[tasks.run_release]
command = "cargo"
args = ["run", "--release"]
# END Function outputs

# START Workspaces
[tasks.build_workspace]
command = "cargo"
args = ["build", "--workspace"]
dependencies = ["format"]

[tasks.build_release_workspace]
command = "cargo"
args = ["build", "--release", "--workspace"]
dependencies = ["format"]

[tasks.test_workspace]
command = "cargo"
args = ["test", "--workspace"]
# END Workspaces
[env]
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true
CARGO_MAKE_TIME_SUMMARY = true
BREAKER = "----------------------------------------"

ROOT = "${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}"

#PROFILE = "${CARGO_MAKE_CARGO_PROFILE}"
PROFILE = "release"
VERSION = "${CARGO_MAKE_PROJECT_VERSION}"
# Name of the output binary
BIN_NAME = "${CARGO_MAKE_PROJECT_NAME}"
# The formatted name of the output binary we want
OUTPUT_BIN_NAME = "${BIN_NAME}_${VERSION}"
# The folder where the binary will be copied to -- /_output_bin_name_dist
DIST_FOLDER = "${ROOT}/_${OUTPUT_BIN_NAME}_dist"
# the FULL path from root WITH EXE - root / target /current_profile / the_bin_name.EXE
FOLDER_BIN_EXE = "${ROOT}/target/${PROFILE}/${BIN_NAME}.exe"

VARS = { script = ['''
echo ""ROOT: ${ROOT}
echo "PROFILE: ${PROFILE}"
echo "VERSION: ${VERSION}"
echo "BIN_NAME: ${BIN_NAME}"
echo "OUTPUT_BIN_NAME: ${OUTPUT_BIN_NAME}"
echo "DIST_FOLDER: ${DIST_FOLDER}"
echo "FOLDER_BIN_EXE: ${FOLDER_BIN_EXE}"
echo "BREAKER: ${BREAKER}"
'''], multi_line = true }

[tasks.print_all]
script_runner = "@duckscript"
script = '''
echo "BREAKER: ${BREAKER}"
echo ""ROOT: ${ROOT}
echo "PROFILE: ${PROFILE}"
echo "VERSION: ${VERSION}"
echo "BIN_NAME: ${BIN_NAME}"
echo "OUTPUT_BIN_NAME: ${OUTPUT_BIN_NAME}"
echo "DIST_FOLDER: ${DIST_FOLDER}"
echo "FOLDER_BIN_EXE: ${FOLDER_BIN_EXE}"
echo "BREAKER: ${BREAKER}"
'''

# START Core bare. min
[tasks.format]
command = "cargo"
args = ["fmt", "--", "--emit=files"]

[tasks.clean]
command = "cargo"
args = ["clean"]

[tasks.build]
command = "cargo"
args = ["build"]
dependencies = ["format"]

[tasks.build_release]
command = "cargo"
args = ["build", "--release"]
dependencies = ["format"]

[tasks.docs]
command = "cargo"
args = ["doc", "--no-deps"]
# END Core bare. min

# START Tests
[tasks.test]
command = "cargo"
args = ["test", "--", "--nocapture"]

[tasks.test_all]
command = "cargo"
args = ["test", "--all", "--", "--nocapture"]
# END Tests

# START Function outputs
[tasks.run]
command = "cargo"
args = ["run"]

[tasks.run_release]
command = "cargo"
args = ["run", "--release"]
# END Function outputs

# START Workspaces
[tasks.build_workspace]
command = "cargo"
args = ["build", "--workspace"]
dependencies = ["format"]

[tasks.build_release_workspace]
command = "cargo"
args = ["build", "--release", "--workspace"]
dependencies = ["format"]

[tasks.test_workspace]
command = "cargo"
args = ["test", "--workspace"]
# END Workspaces
127 changes: 106 additions & 21 deletions build/dist-tasks.toml
Original file line number Diff line number Diff line change
@@ -1,38 +1,123 @@
[tasks.print_outs]
script_runner = "@duckscript"
script = '''
echo "BREAKER: ${BREAKER}"
echo "winodows would be args: "FROM:: ${FOLDER_BIN_EXE}""
echo "winodows would be args: "TO:: ${DIST_FOLDER}/${OUTPUT_BIN_NAME}.exe""
echo "BREAKER: ${BREAKER}"
'''

[tasks.clear_dist_if_exist]
command = "rm"
windows.args = ["-Force", "-Recurse", "${DIST_FOLDER}/", "-ErrorAction", "SilentlyContinue"]
linux.args = ["-rf", "${DIST_FOLDER}/"]
windows.command = "pwsh.exe"
windows.args = [
"-Command",
"Remove-Item",
"-Recurse",
"-Force",
"${DIST_FOLDER}/",
"-ErrorAction",
"SilentlyContinue"
]
ignore_errors = true # REQUIRED as - if the dir doesn't exist, SilenlyContinue does nothing really

[tasks.create_dist]
command = "mkdir"
args = ["-p", "${DIST_FOLDER}/"]
linux.command = "mkdir"
linux.args = ["-p", "${DIST_FOLDER}/"]
windows.command = "mkdir"
windows.args = ["${DIST_FOLDER}/"]

[tasks.create_showcase_dist]
command = "mkdir"
args = ["-p", "${DIST_FOLDER}/showcase/"]
linux.command = "mkdir"
linux.args = ["-p", "${DIST_FOLDER}/showcase/"]
windows.command = "mkdir"
windows.args = ["${DIST_FOLDER}/showcase/"]
dependencies = ["create_dist"]

[tasks.copy_readme_to_dist]
command = "cp"
args = ["${ROOT}/README.md", "${DIST_FOLDER}/"]
linux.command = "cp"
linux.args = ["${ROOT}/README.md", "${DIST_FOLDER}/"]
windows.command = "pwsh.exe"
windows.args = [
"-Command",
"Copy-Item",
"-Path",
"${ROOT}/README.md",
"-Destination",
"${DIST_FOLDER}",
]
dependencies = ["create_dist"]

[tasks.copy_release_to_dist]
command = "cp"
windows.args = ["${FOLDER_BIN_EXE}", "${DIST_FOLDER}/${OUTPUT_BIN_NAME}.exe"]
linux.command = "cp"
linux.args = ["${FOLDER_BIN_EXE}", "${DIST_FOLDER}/${OUTPUT_BIN_NAME}"]
dependencies = ["create_dist", "build_release"]
windows.command = "pwsh.exe"
windows.args = [
"-Command",
"Copy-Item",
"-Path",
"${FOLDER_BIN_EXE}",
"-Destination",
"${DIST_FOLDER}/${OUTPUT_BIN_NAME}.exe",
]
dependencies = ["create_dist"]

[tasks.compress_dist]
linux.command = "tar"
linux.args = [
"-czvf",
"${DIST_FOLDER}.tar.gz",
"${DIST_FOLDER}/",
"mv",
"${DIST_FOLDER}.tar.gz",
"${DIST_FOLDER}/",
]

windows.command = "pwsh.exe"
windows.args = [
"-Command",
"Compress-Archive",
"-Path",
"${DIST_FOLDER}",
"-DestinationPath",
"${DIST_FOLDER}.zip",
]
dependencies = ["create_dist"]

[tasks.move_compressed_to_dist]
linux.command = "mv"
linux.args = ["${DIST_FOLDER}.tar.gz", "${DIST_FOLDER}/"]

windows.command = "pwsh.exe"
windows.args = [
"-Command",
"Move-Item",
"-Path",
"${DIST_FOLDER}.zip",
"-Destination",
"${DIST_FOLDER}/"
]

# Lets any streaming tasks finish
[tasks.sleep]
linux.command = "sleep"
linux.args = ["1"]
windows.command = "pwsh.exe"
windows.args = ["-Command", "Start-Sleep", "-Seconds", "1"]

[tasks.build_release_dist]
env.PROFILE = "release"
dependencies = [
"build_release_workspace",
"build",
"test_workspace",
"test_all",
# "create_dist",
# "create_showcase_dist",
# "copy_readme_to_dist",
# "copy_release_to_dist",
# "print_all",
# "docs",
]
"a",
"clear_dist_if_exist",
"create_dist",
"create_showcase_dist",
"copy_readme_to_dist",
"copy_release_to_dist",
"docs",
"print_all",
"sleep",
"compress_dist",
"move_compressed_to_dist",
]
14 changes: 14 additions & 0 deletions build/push_event.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"ref": "refs/tags/v2.1.0",
"repository": {
"name": "wow_some_name_repo",
"owner": {
"name": "wow_some_username"
}
},
"head_commit": {
"id": "abc123"
},
"before": "abc122"
}

0 comments on commit 8a19ae1

Please sign in to comment.