Skip to content

Commit

Permalink
Merge pull request #55 from the-mad-statter/dev
Browse files Browse the repository at this point in the history
add badge_github_release()
  • Loading branch information
GuangchuangYu authored Jun 8, 2024
2 parents 698a53e + 72f4d28 commit 0657b78
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/r.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
Package: badger
Title: Badge for R Package
Version: 0.2.3.002
Version: 0.2.4
Authors@R: c(
person("Guangchuang", "Yu", email = "[email protected]", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-6485-8781")),
person("Gregor", "de Cillia", email = "[email protected]", role = "ctb"),
person("Dirk", "Eddelbuettel", email = "[email protected]", role = "ctb"),
person("Maëlle", "Salmon", role = "ctb"),
person("Robrecht", "Cannoodt", email = "[email protected]", role = "ctb", comment = c(ORCID = "0000-0003-3641-729X", github = "rcannood")),
person("Alexander", "Rossell Hayes", email = "[email protected]", role = "ctb", comment = c(ORCID = "0000-0001-9412-0457", github = "rossellhayes")),
person("Waldir", "Leoncio", email = "[email protected]", role = "ctb")
person("Waldir", "Leoncio", email = "[email protected]", role = "ctb"),
person("Matthew", "Schuelke", email = "[email protected]", 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:
Expand All @@ -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
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
15 changes: 15 additions & 0 deletions R/badge.R
Original file line number Diff line number Diff line change
Expand Up @@ -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, ")")
}
21 changes: 21 additions & 0 deletions man/badge_github_release.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/badger-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion tests/testthat/test-badges.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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"
)
)
})

0 comments on commit 0657b78

Please sign in to comment.