mirror of
https://github.com/agdamsbo/daDoctoR.git
synced 2024-11-22 03:40:23 +01:00
added auto version numbering
This commit is contained in:
parent
1c1e76414a
commit
f2e586c94b
@ -1,6 +1,6 @@
|
|||||||
Package: daDoctoR
|
Package: daDoctoR
|
||||||
Title: daDoctoR
|
Title: daDoctoR
|
||||||
Version: 0.0.0.9000
|
Version: 0.0.0.9003
|
||||||
Authors@R: c(
|
Authors@R: c(
|
||||||
person("Andreas", "Gammelgaard Damsbo", email = "agdamsbo@pm.me", role = c("cre", "aut")))
|
person("Andreas", "Gammelgaard Damsbo", email = "agdamsbo@pm.me", role = c("cre", "aut")))
|
||||||
Description: Tools for Danish health research. A collection of
|
Description: Tools for Danish health research. A collection of
|
||||||
|
19
packing.R
19
packing.R
@ -3,18 +3,15 @@ library(devtools)
|
|||||||
|
|
||||||
# Packing for publication
|
# Packing for publication
|
||||||
|
|
||||||
setwd("/Users/andreas/Documents/GitHub/daDoctoR"); document()
|
source("/Users/andreas/Documents/GitHub/daDoctoR/updatePackageVersion.R")
|
||||||
|
|
||||||
|
setwd("/Users/andreas/Documents/GitHub/daDoctoR")
|
||||||
|
|
||||||
|
updatePackageVersion()
|
||||||
|
|
||||||
|
document()
|
||||||
|
|
||||||
|
|
||||||
setwd(".."); install("daDoctoR")
|
# Inspiration: "https://hilaryparker.com/2014/04/29/writing-an-r-package-from-scratch/"
|
||||||
|
|
||||||
# Install from GitHub
|
|
||||||
|
|
||||||
setwd("/"); devtools::install_github('agdamsbo/daDoctoR'); library(daDoctoR)
|
|
||||||
|
|
||||||
"https://hilaryparker.com/2014/04/29/writing-an-r-package-from-scratch/"
|
|
||||||
|
|
||||||
# Fixes
|
|
||||||
|
|
||||||
remove.packages("daDoctoR"); .rs.restartR()
|
|
||||||
|
|
||||||
|
13
update local version.R
Normal file
13
update local version.R
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# Install new version
|
||||||
|
|
||||||
|
# Remove
|
||||||
|
|
||||||
|
remove.packages("daDoctoR")
|
||||||
|
.rs.restartR()
|
||||||
|
|
||||||
|
# Install from GitHub
|
||||||
|
|
||||||
|
setwd("/")
|
||||||
|
devtools::install_github('agdamsbo/daDoctoR')
|
||||||
|
|
||||||
|
library(daDoctoR)
|
32
updatePackageVersion.R
Normal file
32
updatePackageVersion.R
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
updatePackageVersion <- function(packageLocation ="."){
|
||||||
|
## Read DESCRIPTION file
|
||||||
|
desc <- readLines(file.path(packageLocation, "DESCRIPTION"))
|
||||||
|
|
||||||
|
## Find the line where the version is defined
|
||||||
|
vLine <- grep("^Version\\:", desc)
|
||||||
|
|
||||||
|
## Extract version number
|
||||||
|
vNumber <- gsub("^Version\\:\\s*", "", desc[vLine])
|
||||||
|
|
||||||
|
## Split the version number into two; a piece to keep, a piece to increment
|
||||||
|
versionNumber <- strsplit(vNumber, "\\.")[[1]]
|
||||||
|
versionParts <- length(versionNumber)
|
||||||
|
vNumberKeep <- paste(versionNumber[1:(versionParts-1)], sep= "", collapse= ".")
|
||||||
|
vNumberUpdate <- versionNumber[versionParts]
|
||||||
|
|
||||||
|
## Replace old version number with new one (increment by 1)
|
||||||
|
oldVersion <- as.numeric(vNumberUpdate)
|
||||||
|
newVersion <- oldVersion + 1
|
||||||
|
|
||||||
|
## Build final version number
|
||||||
|
vFinal <- paste(vNumberKeep, newVersion, sep = ".")
|
||||||
|
|
||||||
|
## Update DESCRIPTION file (in R)
|
||||||
|
desc[vLine] <- paste0("Version: ", vFinal )
|
||||||
|
|
||||||
|
## Update the actual DESCRIPTION file
|
||||||
|
writeLines(desc, file.path(packageLocation, "DESCRIPTION"))
|
||||||
|
|
||||||
|
## Return the updated version number to screen
|
||||||
|
return(vFinal)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user