create correct s3 paths for upload
This commit is contained in:
parent
c42e2be4a6
commit
1721294469
1 changed files with 11 additions and 21 deletions
32
R/upload.R
32
R/upload.R
|
|
@ -1,32 +1,22 @@
|
||||||
#' @importFrom paws.storage s3
|
#' @importFrom s3fs s3_file_exists s3_file_upload s3_file_system
|
||||||
#' @export
|
#' @export
|
||||||
upload_single_binary_to_s3 <- function(
|
upload_single_binary_to_s3 <- function(
|
||||||
endpoint = "https://s3.eu-central-003.backblazeb2.com",
|
endpoint = "https://s3.eu-central-003.backblazeb2.com",
|
||||||
region = "eu-central-003",
|
region = "eu-central-003",
|
||||||
|
bucket = "devxy-arm64-r-binaries",
|
||||||
local_build_root = "/root", codename = NULL,
|
local_build_root = "/root", codename = NULL,
|
||||||
package_name, tag,
|
package_name, tag,
|
||||||
r_version_minor = NULL, build_for_minor = TRUE,
|
r_version_minor = NULL, build_for_minor = FALSE,
|
||||||
force = FALSE,
|
force = FALSE,
|
||||||
debug = FALSE) {
|
debug = FALSE) {
|
||||||
|
|
||||||
codename <- set_codename(codename)
|
codename <- set_codename(codename)
|
||||||
|
|
||||||
if (is.null(r_version_minor)) {
|
if (is.null(r_version_minor)) {
|
||||||
r_version_minor <- sub("R version (\\d+\\.\\d+).*", "\\1", R.Version()$version.string)
|
r_version_minor <- sub("R version (\\d+\\.\\d+).*", "\\1", R.Version()$version.string)
|
||||||
}
|
}
|
||||||
|
|
||||||
# create directory structure
|
local_bin_path <- set_bin_path(r_version_minor, build_for_minor, local_build_root = local_build_root, codename)
|
||||||
if (is.null(r_version_minor) && !build_for_minor) {
|
remote_bin_path <- set_bin_path(r_version_minor, build_for_minor, local_build_root = bucket, codename)
|
||||||
dir_out_bin <- sprintf(
|
|
||||||
"%s/__linux__/%s/latest/src/contrib",
|
|
||||||
local_build_root, codename
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
dir_out_bin <- sprintf(
|
|
||||||
"%s/__linux__/%s/%s/latest/src/contrib",
|
|
||||||
local_build_root, codename, r_version_minor
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (debug) {
|
if (debug) {
|
||||||
cli::cli_alert_danger("DEBUG: dir_out_bin: {dir_out_bin}, codename: {codename}")
|
cli::cli_alert_danger("DEBUG: dir_out_bin: {dir_out_bin}, codename: {codename}")
|
||||||
|
|
@ -41,19 +31,19 @@ upload_single_binary_to_s3 <- function(
|
||||||
)
|
)
|
||||||
|
|
||||||
tarball_name <- sprintf("%s_%s.tar.gz", package_name, tag)
|
tarball_name <- sprintf("%s_%s.tar.gz", package_name, tag)
|
||||||
exists <- s3fs::s3_file_exists(sprintf("devxy-arm64-r-binaries/__linux__/%s/%s/latest/src/contrib/%s", codename, r_version_minor, tarball_name))
|
exists <- s3fs::s3_file_exists(sprintf("%s/%s", remote_bin_path, tarball_name))
|
||||||
|
|
||||||
if (!exists && !force) {
|
if (!exists && !force) {
|
||||||
cli::cli_alert_info("{.fun build_single_tag}: 5. Uploading {.pkg {package_name}} {.strong {tag}} to S3.")
|
cli::cli_alert_info("{.fun build_single_tag}: 5. Uploading {.pkg {package_name}} {.field {tag}} to S3.")
|
||||||
s3fs::s3_file_upload(
|
s3fs::s3_file_upload(
|
||||||
sprintf("%s/%s", dir_out_bin, tarball_name),
|
sprintf("%s/%s", local_bin_path, tarball_name),
|
||||||
sprintf("devxy-arm64-r-binaries/__linux__/%s/%s/latest/src/contrib/%s", codename, r_version_minor, tarball_name)
|
sprintf("%s/%s", remote_bin_path, tarball_name)
|
||||||
)
|
)
|
||||||
} else if (exists && force) {
|
} else if (exists && force) {
|
||||||
cli::cli_alert_info("{.fun upload_to_s3}: Force uploading package {.pkg {package_name}} {.path {tag}} because force = TRUE was set.")
|
cli::cli_alert_info("{.fun upload_to_s3}: Force uploading package {.pkg {package_name}} {.path {tag}} because force = TRUE was set.")
|
||||||
s3fs::s3_file_upload(
|
s3fs::s3_file_upload(
|
||||||
sprintf("%s/%s", dir_out_bin, tarball_name),
|
sprintf("%s", local_bin_path, tarball_name),
|
||||||
sprintf("devxy-arm64-r-binaries/__linux__/%s/%s/latest/src/contrib/%s", codename, r_version_minor, tarball_name),
|
sprintf("%s", remote_bin_path, tarball_name),
|
||||||
overwrite = TRUE
|
overwrite = TRUE
|
||||||
)
|
)
|
||||||
} else if (exists && !force) {
|
} else if (exists && !force) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue