From ae9e3c647eafb823c57f64a2f5c24de8b876c1ab Mon Sep 17 00:00:00 2001 From: gautam8387 Date: Tue, 11 Aug 2026 15:49:16 +0200 Subject: [PATCH 1/3] package versioning; wip --- .gitattributes | 1 + .github/workflows/release.yaml | 45 ++++++++++++++++++ DESCRIPTION | 2 +- R/zzz.R | 2 +- bootstrap.R | 86 ++++++++++++++++++++++++++++++++++ 5 files changed, 134 insertions(+), 2 deletions(-) create mode 100644 .gitattributes create mode 100644 .github/workflows/release.yaml create mode 100644 bootstrap.R diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..229987c --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +bootstrap.R export-subst diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..64716d7 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,45 @@ +name: Validate R release + +on: + release: + types: [published] + +permissions: + contents: read + +jobs: + release: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.release.tag_name }} + + - name: Validate release tag + env: + RELEASE_TAG: ${{ github.event.release.tag_name }} + run: | + package_version="$(awk -F ': *' '$1 == "Version" {print $2}' DESCRIPTION)" + if [ "$RELEASE_TAG" != "v$package_version" ]; then + echo "::error::Release tag $RELEASE_TAG does not match DESCRIPTION version $package_version" + exit 1 + fi + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 + with: + r-version: release + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::rcmdcheck + needs: check + + - name: Build source package + run: R CMD build --no-manual --compact-vignettes=gs+qpdf . + + - name: Check source package + run: R CMD check --no-manual CyteTypeR_*.tar.gz diff --git a/DESCRIPTION b/DESCRIPTION index 070b801..709c4fb 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: CyteTypeR Title: CyteType for R -Version: 0.4.3 +Version: 0.5.0 Description: CyteTypeR is the R version of CyteType python package. Authors@R: person("Nygen Analytics AB", , ,"contact@nygen.io", role = c("aut", "cre")) diff --git a/R/zzz.R b/R/zzz.R index fd34a94..3af02e8 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -37,7 +37,7 @@ if (package_version(latest) > package_version(current)) { packageStartupMessage( "A newer version of CyteTypeR is available (", current, " -> ", latest, "). ", - "Run remotes::install_github('NygenAnalytics/CyteTypeR') to update." + "Run devtools::install_github('NygenAnalytics/CyteTypeR') to update." ) } }, error = function(e) NULL) diff --git a/bootstrap.R b/bootstrap.R new file mode 100644 index 0000000..8c19a41 --- /dev/null +++ b/bootstrap.R @@ -0,0 +1,86 @@ +args <- commandArgs(trailingOnly = TRUE) +if (length(args) > 1L) { + stop("Usage: Rscript bootstrap.R [expected-release-tag]") +} + +archiveDescribe <- "$Format:%(describe:tags,match=v[0-9]*)$" +describe <- tryCatch( + suppressWarnings( + system2( + "git", + c("describe", "--tags", "--long", "--dirty", "--match", shQuote("v[0-9]*")), + stdout = TRUE, + stderr = TRUE + ) + ), + error = function(error) structure(conditionMessage(error), status = 1L) +) +status <- attr(describe, "status") +if (!is.null(status) && status != 0L) { + if (startsWith(archiveDescribe, "$Format:")) { + stop("Unable to derive the package version from Git tags: ", paste(describe, collapse = "\n")) + } + describe <- archiveDescribe +} +if (length(describe) != 1L) { + stop("Expected one version description") +} + +exactMatches <- regmatches( + describe, + regexec("^v([0-9]+\\.[0-9]+\\.[0-9]+)$", describe) +)[[1]] +if (length(exactMatches) != 0L) { + baseVersion <- exactMatches[[2]] + distance <- 0L + dirty <- FALSE +} else { + matches <- regmatches( + describe, + regexec( + "^v([0-9]+\\.[0-9]+\\.[0-9]+)-([0-9]+)-g[0-9a-f]+(-dirty)?$", + describe + ) + )[[1]] + if (length(matches) == 0L) { + stop("Git tag must use the form vX.Y.Z: ", describe) + } + + baseVersion <- matches[[2]] + distance <- as.integer(matches[[3]]) + dirty <- length(matches) == 4L && identical(matches[[4]], "-dirty") +} + +if (distance == 0L && !dirty) { + packageVersion <- baseVersion +} else { + packageVersion <- paste(baseVersion, "9000", distance, sep = ".") + if (dirty) { + packageVersion <- paste(packageVersion, "1", sep = ".") + } +} + +if (length(args) == 1L) { + expectedTag <- args[[1]] + if (!grepl("^v[0-9]+\\.[0-9]+\\.[0-9]+$", expectedTag)) { + stop("Expected release tag must use the form vX.Y.Z: ", expectedTag) + } + if (distance != 0L || dirty || !identical(packageVersion, sub("^v", "", expectedTag))) { + stop( + "Release tag does not match the checked-out commit: expected ", + expectedTag, + ", derived ", + packageVersion + ) + } +} + +description <- readLines("DESCRIPTION", warn = FALSE) +versionLine <- grep("^Version:", description) +if (length(versionLine) != 1L) { + stop("DESCRIPTION must contain exactly one Version field") +} +description[[versionLine]] <- paste("Version:", packageVersion) +writeLines(description, "DESCRIPTION", useBytes = TRUE) + +cat(packageVersion, "\n", sep = "") From 31e9c87c67ab5b682094442d9453cbf80a9bc5c9 Mon Sep 17 00:00:00 2001 From: gautam8387 Date: Tue, 11 Aug 2026 16:35:49 +0200 Subject: [PATCH 2/3] wip --- .gitattributes | 1 - .github/workflows/release.yaml | 33 +++---------- README.md | 2 + bootstrap.R | 86 ---------------------------------- 4 files changed, 9 insertions(+), 113 deletions(-) delete mode 100644 .gitattributes delete mode 100644 bootstrap.R diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 229987c..0000000 --- a/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -bootstrap.R export-subst diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 64716d7..023981b 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,45 +1,26 @@ -name: Validate R release +name: Validate R version tag on: - release: - types: [published] + push: + tags: + - "v*" permissions: contents: read jobs: - release: + validate-version: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - with: - ref: ${{ github.event.release.tag_name }} - - name: Validate release tag + - name: Validate tag against DESCRIPTION env: - RELEASE_TAG: ${{ github.event.release.tag_name }} + RELEASE_TAG: ${{ github.ref_name }} run: | package_version="$(awk -F ': *' '$1 == "Version" {print $2}' DESCRIPTION)" if [ "$RELEASE_TAG" != "v$package_version" ]; then echo "::error::Release tag $RELEASE_TAG does not match DESCRIPTION version $package_version" exit 1 fi - - - uses: r-lib/actions/setup-pandoc@v2 - - - uses: r-lib/actions/setup-r@v2 - with: - r-version: release - use-public-rspm: true - - - uses: r-lib/actions/setup-r-dependencies@v2 - with: - extra-packages: any::rcmdcheck - needs: check - - - name: Build source package - run: R CMD build --no-manual --compact-vignettes=gs+qpdf . - - - name: Check source package - run: R CMD check --no-manual CyteTypeR_*.tar.gz diff --git a/README.md b/README.md index 71d6e1e..e0ce5ab 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,8 @@ For AnnData workflows, use [CyteType](https://github.com/NygenAnalytics/CyteType). > [!IMPORTANT] +> Already installed CyteTypeR? Open R and run `devtools::install_github("NygenAnalytics/CyteTypeR", force = TRUE)` to update to the latest version before you start. +> > CyteType requires an API key. API use is free for academic and non-commercial research. Commercial API use requires a [license](#license). ## Why CyteTypeR? diff --git a/bootstrap.R b/bootstrap.R deleted file mode 100644 index 8c19a41..0000000 --- a/bootstrap.R +++ /dev/null @@ -1,86 +0,0 @@ -args <- commandArgs(trailingOnly = TRUE) -if (length(args) > 1L) { - stop("Usage: Rscript bootstrap.R [expected-release-tag]") -} - -archiveDescribe <- "$Format:%(describe:tags,match=v[0-9]*)$" -describe <- tryCatch( - suppressWarnings( - system2( - "git", - c("describe", "--tags", "--long", "--dirty", "--match", shQuote("v[0-9]*")), - stdout = TRUE, - stderr = TRUE - ) - ), - error = function(error) structure(conditionMessage(error), status = 1L) -) -status <- attr(describe, "status") -if (!is.null(status) && status != 0L) { - if (startsWith(archiveDescribe, "$Format:")) { - stop("Unable to derive the package version from Git tags: ", paste(describe, collapse = "\n")) - } - describe <- archiveDescribe -} -if (length(describe) != 1L) { - stop("Expected one version description") -} - -exactMatches <- regmatches( - describe, - regexec("^v([0-9]+\\.[0-9]+\\.[0-9]+)$", describe) -)[[1]] -if (length(exactMatches) != 0L) { - baseVersion <- exactMatches[[2]] - distance <- 0L - dirty <- FALSE -} else { - matches <- regmatches( - describe, - regexec( - "^v([0-9]+\\.[0-9]+\\.[0-9]+)-([0-9]+)-g[0-9a-f]+(-dirty)?$", - describe - ) - )[[1]] - if (length(matches) == 0L) { - stop("Git tag must use the form vX.Y.Z: ", describe) - } - - baseVersion <- matches[[2]] - distance <- as.integer(matches[[3]]) - dirty <- length(matches) == 4L && identical(matches[[4]], "-dirty") -} - -if (distance == 0L && !dirty) { - packageVersion <- baseVersion -} else { - packageVersion <- paste(baseVersion, "9000", distance, sep = ".") - if (dirty) { - packageVersion <- paste(packageVersion, "1", sep = ".") - } -} - -if (length(args) == 1L) { - expectedTag <- args[[1]] - if (!grepl("^v[0-9]+\\.[0-9]+\\.[0-9]+$", expectedTag)) { - stop("Expected release tag must use the form vX.Y.Z: ", expectedTag) - } - if (distance != 0L || dirty || !identical(packageVersion, sub("^v", "", expectedTag))) { - stop( - "Release tag does not match the checked-out commit: expected ", - expectedTag, - ", derived ", - packageVersion - ) - } -} - -description <- readLines("DESCRIPTION", warn = FALSE) -versionLine <- grep("^Version:", description) -if (length(versionLine) != 1L) { - stop("DESCRIPTION must contain exactly one Version field") -} -description[[versionLine]] <- paste("Version:", packageVersion) -writeLines(description, "DESCRIPTION", useBytes = TRUE) - -cat(packageVersion, "\n", sep = "") From 45ae03650aa6aba7eeefc94ff9166291c4da2f9b Mon Sep 17 00:00:00 2001 From: gautam8387 Date: Tue, 11 Aug 2026 16:38:39 +0200 Subject: [PATCH 3/3] wip --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 709c4fb..7db99e2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: CyteTypeR Title: CyteType for R -Version: 0.5.0 +Version: 0.5.1 Description: CyteTypeR is the R version of CyteType python package. Authors@R: person("Nygen Analytics AB", , ,"contact@nygen.io", role = c("aut", "cre"))