-
Notifications
You must be signed in to change notification settings - Fork 28
/
build-cran.R
executable file
·99 lines (69 loc) · 2.84 KB
/
build-cran.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/local/bin/Rscript
library(rhub)
library(devtools)
library(git2r)
library(glue)
library(rmarkdown)
library(rstudioapi)
# Check version number is up to date----------------------------------------------------------------
v <- devtools::as.package('.')$version
if (grepl("9000", v)) stop('Still using development version. Use usethis::use_version()')
# Check git is up to date --------------------------------------------------------------------------
gdiff <- git2r::diff(git2r::repository())
if (length(gdiff) > 0) stop('Working tree differs from last commit, please make commits!')
# nb this may fail for some reason
# Build vignettes manually ----------------------------------------------
pdf_output_formats <- list(
"design-principles.Rmd" = pdf_document(latex_engine = "xelatex"),
"huxreg.Rmd" = pdf_document(latex_engine = "xelatex"),
"huxtable.Rmd" = pdf_document(
latex_engine = "xelatex",
toc = TRUE,
toc_depth = 2
)
)
for (f in list.files("docs", pattern = "*.Rmd", full.names = TRUE)) {
filename <- basename(f)
message("Rendering ", f)
filename_no_ext <- sub("\\.Rmd$", "", filename)
rmarkdown::render(f,
output_format = "html_document",
output_dir = "vignettes",
output_file = paste0(filename_no_ext, "-html"))
rmarkdown::render(f,
output_format = pdf_output_formats[[filename]],
output_dir = "vignettes",
output_file = paste0(filename_no_ext, "-pdf"))
}
setwd("vignettes")
knitr::knit("../docs/themes.Rhtml", "themes-html.html")
setwd("..")
# Run R CMD check ----------------------------------------------------------------------------------
# this automatically builds the package
chk <- devtools::check(
env_vars = c('RSTUDIO_PANDOC' = '/Applications/RStudio.app/Contents/MacOS/pandoc'),
document = FALSE,
remote = TRUE
)
# manual section --------
# may not work; if so just run the script in the main window.
rstudioapi::jobRunScript("check-reverse-dependencies.R", exportEnv = "revdep_results")
# run checks
devtools::check_mac_release()
# asks manual questions
devtools::check_win_devel()
# asks manual questions
devtools::check_win_release()
# update CRAN-comments.md
# Tag new version
newtag <- paste0('v', v, '-rc')
tags <- git2r::tags()
tags <- grep(newtag, names(tags), fixed = TRUE, value = TRUE)
tags <- as.numeric(gsub(newtag, '', tags))
rc <- if (length(tags)) as.integer(max(tags) + 1) else 1L
newtag <- paste0(newtag, rc)
cat('\nTagging current version as: ', newtag, '\n')
tag(repository('.'), newtag, message = paste('CRAN release candidate for', v))
system2('git', c('push', '--tags'))
# now release!
devtools::release()