Install packages from GitHub
Usage
installFromGitHub(
repo,
tag,
branch,
lib = .libPaths()[[1L]],
reinstall = TRUE,
...
)Arguments
- repo
character. Repository address(es) in the formatowner/repo.- tag
characterormissing. Release version tag. Specific release must match the tag on GitHub (e.g."v1.0.0"). Required except whenbranchis declared.- branch
characterormissing. Branch name (e.g."develop"). Can specify this instead oftag.- lib
character. Destination library directory path. Defaults to the first element of.libPaths().- reinstall
logical(1). Force reinstallation of any existing packages.- ...
Passthrough arguments to
install().
Details
This variant doesn't require GITHUB_PAT. If you have a GITHUB_PAT
defined, can use install() directly instead. Intended for use inside
container images, where a PAT may not be used.
GitHub API
All releases JSON:
https://api.github.com/repos/:owner/:repo/releasesLatest release JSON:
https://api.github.com/repos/:owner/:repo/releases/latestSpecific release JSON (requires numeric release ID, not tag name):
https://api.github.com/repos/:owner/:repo/releases/:release_idSpecific tagged release tarball:
https://github.com/:owner/:repo/archive/:tag.tar.gz
Examples
testlib <- file.path(tempdir(), "testlib")
unlink(testlib, recursive = TRUE)
out <- installFromGitHub(
repo = paste(
"acidgenomics",
"r-goalie",
sep = "/"
),
tag = "v0.5.2",
dependencies = FALSE,
lib = testlib,
reinstall = TRUE
)
#> untar: using cmd = ‘/usr/bin/tar -xf '/var/folders/9b/4gh0pghx1b71jjd0wjh5mj880000gn/T//RtmpzroEwl/file128e4300422de.tar.gz' -C '/private/var/folders/9b/4gh0pghx1b71jjd0wjh5mj880000gn/T/RtmpzroEwl/EUrhFDv6iY-174821502862364/untar-VqGfFI'’
#> Installing 'goalie' with 'utils::install.packages' in '/private/var/folders/9b/4gh0pghx1b71jjd0wjh5mj880000gn/T/RtmpzroEwl/testlib'.
print(out)
#> $repo
#> [1] "acidgenomics/r-goalie"
#>
#> $lib
#> [1] "/private/var/folders/9b/4gh0pghx1b71jjd0wjh5mj880000gn/T/RtmpzroEwl/testlib"
#>
#> $installed
#> acidgenomics/r-goalie
#> TRUE
#>
sort(list.dirs(path = testlib, full.names = FALSE, recursive = FALSE))
#> [1] "goalie"
unlink(testlib, recursive = TRUE)