-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: Add a renaming script for CI release uplaoding
Signed-off-by: Ali Sajid Imami <[email protected]>
- Loading branch information
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env Rscript | ||
|
||
# This script takes in a name and renames it to include the current R | ||
# version and the current platform. It is intended to be used to rename | ||
# packages that are being uploaded to releases on GitHub. | ||
|
||
## Parse the first argument as the package name + package version | ||
args <- commandArgs(trailingOnly = TRUE) | ||
if (length(args) != 1L) { | ||
stop("Usage: rename-package.R <package-name>") | ||
} | ||
|
||
message("Received package name: ", args[[1L]]) | ||
|
||
packageName <- strsplit(args, "_")[[1L]][[1L]] | ||
message("Package name: ", packageName) | ||
packageVersion <- strsplit(args, "_")[[1L]][[2L]] | ||
message("Package version: ", packageVersion) | ||
|
||
newName <- paste( | ||
packageName, paste("R", | ||
getRversion(), | ||
sep = "-" | ||
), | ||
R.version[["platform"]], | ||
paste0("v", packageVersion), | ||
sep = "_" | ||
) | ||
|
||
message("Renaming package to: ", newName) | ||
|
||
value <- file.rename(args[[1L]], newName) | ||
|
||
if (value) { | ||
message("Successfully renamed package to: ", newName) | ||
} else { | ||
stop("Failed to rename package to: ", newName) | ||
} |