From affd8009d88ded5b15e41e74b82cc335dc4041f8 Mon Sep 17 00:00:00 2001 From: Ali Sajid Imami <395482+AliSajid@users.noreply.github.com> Date: Fri, 10 May 2024 14:11:18 -0400 Subject: [PATCH] build: Add a renaming script for CI release uplaoding Signed-off-by: Ali Sajid Imami <395482+AliSajid@users.noreply.github.com> --- utilities/bump-version.sh | 1 + utilities/rename-package.R | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100755 utilities/rename-package.R diff --git a/utilities/bump-version.sh b/utilities/bump-version.sh index 5844b331..778b6f24 100755 --- a/utilities/bump-version.sh +++ b/utilities/bump-version.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -euo pipefail # Get the commit message of the latest commit commit_message=$(git log -1 --pretty=%B) diff --git a/utilities/rename-package.R b/utilities/rename-package.R new file mode 100755 index 00000000..d8426745 --- /dev/null +++ b/utilities/rename-package.R @@ -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 ") +} + +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) +}