From 72f4d28cdb58ae06ab3fc4e24a3279bd07943154 Mon Sep 17 00:00:00 2001 From: Matthew Schuelke Date: Fri, 7 Jun 2024 23:33:51 -0500 Subject: [PATCH] add badge_github_release() --- .github/workflows/r.yml | 2 +- DESCRIPTION | 7 ++++--- NAMESPACE | 1 + NEWS.md | 5 +++++ R/badge.R | 15 +++++++++++++++ man/badge_github_release.Rd | 21 +++++++++++++++++++++ man/badger-package.Rd | 1 + tests/testthat/test-badges.R | 9 ++++++++- 8 files changed, 56 insertions(+), 5 deletions(-) create mode 100644 man/badge_github_release.Rd diff --git a/.github/workflows/r.yml b/.github/workflows/r.yml index 22b8e64..c07adcf 100644 --- a/.github/workflows/r.yml +++ b/.github/workflows/r.yml @@ -35,7 +35,7 @@ jobs: R_KEEP_PKG_SOURCE: yes steps: - name: Checking out the repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setting up pandoc uses: r-lib/actions/setup-pandoc@v2 diff --git a/DESCRIPTION b/DESCRIPTION index 881ed7a..07c76ba 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: badger Title: Badge for R Package -Version: 0.2.3.002 +Version: 0.2.4 Authors@R: c( person("Guangchuang", "Yu", email = "guangchuangyu@gmail.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-6485-8781")), person("Gregor", "de Cillia", email = "de.cillia.gregor@gmail.com", role = "ctb"), @@ -8,7 +8,8 @@ Authors@R: c( person("Maƫlle", "Salmon", role = "ctb"), person("Robrecht", "Cannoodt", email = "rcannood@gmail.com", role = "ctb", comment = c(ORCID = "0000-0003-3641-729X", github = "rcannood")), person("Alexander", "Rossell Hayes", email = "alexander@rossellhayes.com", role = "ctb", comment = c(ORCID = "0000-0001-9412-0457", github = "rossellhayes")), - person("Waldir", "Leoncio", email = "w.l.netto@medisin.uio.no", role = "ctb") + person("Waldir", "Leoncio", email = "w.l.netto@medisin.uio.no", role = "ctb"), + person("Matthew", "Schuelke", email = "matt@themadstatter.com", role = "ctb", comment = c(ORCID = "0000-0001-5755-1725", github = "the-mad-statter")) ) Description: Query information and generate badge for using in README and GitHub Pages. Depends: @@ -25,4 +26,4 @@ ByteCompile: true URL: https://github.com/GuangchuangYu/badger BugReports: https://github.com/GuangchuangYu/badger/issues Encoding: UTF-8 -RoxygenNote: 7.3.0 +RoxygenNote: 7.3.1 diff --git a/NAMESPACE b/NAMESPACE index 24a6575..de630ac 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -17,6 +17,7 @@ export(badge_devel) export(badge_doi) export(badge_download_bioc) export(badge_github_actions) +export(badge_github_release) export(badge_github_version) export(badge_last_commit) export(badge_license) diff --git a/NEWS.md b/NEWS.md index 94b7835..09dbfe9 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,8 @@ +# badger 0.2.4 + ++ add github release badge and test (2024-06-07, Fri, #54) ++ update codecov badge test to match merge (2023-07-25, Tue, #53) + # badger 0.2.3.002 + update codecov badge (2023-07-25, Tue, #53) diff --git a/R/badge.R b/R/badge.R index 3f30cc1..83adeb5 100644 --- a/R/badge.R +++ b/R/badge.R @@ -548,3 +548,18 @@ badge_runiverse <- function(pkg = NULL, user = NULL) { "(https://", user, ".r-universe.dev/", pkg, ")" ) } + +##' GitHub Release badge +##' +##' @param ref Reference for a GitHub repository. If \code{NULL} (the default), +##' the reference is determined by the URL field in the DESCRIPTION file. +##' +##' @return badge in markdown syntax +##' @export +##' @author Matt Schuelke +badge_github_release <- function(ref = NULL) { + ref <- currentGitHubRef(ref) + svg <- paste0("https://img.shields.io/github/v/release/", ref) + url <- paste0("https://github.com/", ref, "/releases") + paste0("[![](", svg, ")](", url, ")") +} diff --git a/man/badge_github_release.Rd b/man/badge_github_release.Rd new file mode 100644 index 0000000..1a6a367 --- /dev/null +++ b/man/badge_github_release.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/badge.R +\name{badge_github_release} +\alias{badge_github_release} +\title{GitHub Release badge} +\usage{ +badge_github_release(ref = NULL) +} +\arguments{ +\item{ref}{Reference for a GitHub repository. If \code{NULL} (the default), +the reference is determined by the URL field in the DESCRIPTION file.} +} +\value{ +badge in markdown syntax +} +\description{ +GitHub Release badge +} +\author{ +Matt Schuelke +} diff --git a/man/badger-package.Rd b/man/badger-package.Rd index 5b3bcf8..4006700 100644 --- a/man/badger-package.Rd +++ b/man/badger-package.Rd @@ -27,6 +27,7 @@ Other contributors: \item Robrecht Cannoodt \email{rcannood@gmail.com} (\href{https://orcid.org/0000-0003-3641-729X}{ORCID}) (rcannood) [contributor] \item Alexander Rossell Hayes \email{alexander@rossellhayes.com} (\href{https://orcid.org/0000-0001-9412-0457}{ORCID}) (rossellhayes) [contributor] \item Waldir Leoncio \email{w.l.netto@medisin.uio.no} [contributor] + \item Matthew Schuelke \email{matt@themadstatter.com} (\href{https://orcid.org/0000-0001-5755-1725}{ORCID}) (the-mad-statter) [contributor] } } diff --git a/tests/testthat/test-badges.R b/tests/testthat/test-badges.R index db3f10d..a1edc0d 100644 --- a/tests/testthat/test-badges.R +++ b/tests/testthat/test-badges.R @@ -179,7 +179,7 @@ test_that("Other badges output as expected", { badge_codecov("GuangchuangYu/badger", branch="master"), assembleBadgeOutput( "codecov.io/gh/GuangchuangYu/badger/branch/master/graph/badge.svg", - "codecov.io/gh/GuangchuangYu/badger" + "app.codecov.io/gh/GuangchuangYu/badger" ) ) expect_equal( @@ -206,4 +206,11 @@ test_that("Other badges output as expected", { "CodeFactor", ) ) + expect_equal( + badge_github_release("tidyverse/dplyr"), + assembleBadgeOutput( + "img.shields.io/github/v/release/tidyverse/dplyr", + "github.com/tidyverse/dplyr/releases" + ) + ) })