Skip to content

feat: add R package-aware release handling to draft-release and post-release actions#170

Open
Copilot wants to merge 14 commits into
mainfrom
copilot/support-r-package-structure
Open

feat: add R package-aware release handling to draft-release and post-release actions#170
Copilot wants to merge 14 commits into
mainfrom
copilot/support-r-package-structure

Conversation

Copilot AI commented May 6, 2026

Copy link
Copy Markdown
Contributor

This change adds first-class R package support to release automation. When a repository uses R package structure, release actions now operate on NEWS/NEWS.md and DESCRIPTION (instead of CHANGELOG.md and VERSION), and regenerate CITATION.cff from DESCRIPTION.

  • R package detection + path switching

    • Added DESCRIPTION-based repo detection in release helpers.
    • If defaults are used and an R package is detected:
      • CHANGELOG.mdNEWS.md (or NEWS if present)
      • VERSIONDESCRIPTION (Version: field)
  • Version update semantics for R repos

    • Draft flow updates Version: in DESCRIPTION to the next release version.
    • Post-release flow updates Version: in DESCRIPTION to ${released}.9000 (R-style development versioning, e.g. 1.2.31.2.3.9000).
    • Added strict validation for R release-version input used for this bump and explicit validation when Version: is missing.
  • Semantic-version compatibility hardening

    • Added strict full-string semantic version validation in release-tag handling (get_release_version) before increment checks.
    • This prevents non-release tags such as v1.2.3.9000 from being accepted as release versions.
    • Keeps the .9000 format limited to R post-release development version bumps in DESCRIPTION.
  • CITATION regeneration from DESCRIPTION

    • For R package repos, release flows regenerate CITATION.cff via cffr::cff_write(...) after version updates.
    • Command construction was hardened for safe shell execution.
  • Composite action wiring updates

    • draft-release/action.yml and post-release/action.yml now accept description-filepath (default: DESCRIPTION).
    • Added conditional R setup and cffr dependency install when DESCRIPTION exists.
    • Plumbed description_filepath through to Python release helpers.
  • Focused release behavior coverage

    • Added release tests for:
      • R package detection
      • Draft-release path/version behavior on R package layout
      • Post-release cleanup behavior for DESCRIPTION + citation regeneration
      • R .9000 development-version conversion and invalid-version edge cases
      • Strict semver release-tag validation (including rejection of four-segment tags like v1.2.3.9000)
# draft-release/action.yml / post-release/action.yml (new input + wiring)
inputs:
  description-filepath:
    description: "Path to the R DESCRIPTION file, used when an R package is detected."
    default: "DESCRIPTION"
# release.py (behavior switch)
if is_r_package(description_filepath=description_filepath):
    changelog_filepath = get_news_filepath() if changelog_filepath == "CHANGELOG.md" else changelog_filepath
    version_filepath = description_filepath if version_filepath == "VERSION" else version_filepath

Issues

resolves #98

Copilot AI and others added 2 commits May 6, 2026 22:07
Agent-Logs-Url: https://github.com/CCBR/actions/sessions/1731df8e-d0c5-4e0f-8be6-727b21812646

Co-authored-by: kelly-sovacool <17768269+kelly-sovacool@users.noreply.github.com>
Agent-Logs-Url: https://github.com/CCBR/actions/sessions/1731df8e-d0c5-4e0f-8be6-727b21812646

Co-authored-by: kelly-sovacool <17768269+kelly-sovacool@users.noreply.github.com>
Copilot AI changed the title [WIP] Support R package structure in draft-release and post-release Add R package-aware release handling to draft-release and post-release actions May 6, 2026
Copilot AI requested a review from kelly-sovacool May 6, 2026 22:14

@kelly-sovacool kelly-sovacool left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

R package versions use semantic versioning for releases, but for development versions instead of using tags like v1.2.3-dev, they use a third period followed by a 4-digit number, e.g. v1.2.3.9000. Usually after v1.2.3 is released, the next development version is v1.2.3.9000.

Add support to allow this slight tweak to the versioning system for R packages. But only allow R packages to use this system: all other projects must adhere to semantic versioning.

Copilot AI and others added 2 commits May 6, 2026 22:24
Agent-Logs-Url: https://github.com/CCBR/actions/sessions/d13a8218-f3e5-4d8f-9749-2d510e1ce115

Co-authored-by: kelly-sovacool <17768269+kelly-sovacool@users.noreply.github.com>
Agent-Logs-Url: https://github.com/CCBR/actions/sessions/d13a8218-f3e5-4d8f-9749-2d510e1ce115

Co-authored-by: kelly-sovacool <17768269+kelly-sovacool@users.noreply.github.com>

Copilot AI commented May 6, 2026

Copy link
Copy Markdown
Contributor Author

R package versions use semantic versioning for releases, but for development versions instead of using tags like v1.2.3-dev, they use a third period followed by a 4-digit number, e.g. v1.2.3.9000....

Implemented in 721a1af (with core logic in 02b86dd). R packages now bump to X.Y.Z.9000 after release (e.g., 0.2.0 -> 0.2.0.9000), while non-R projects keep existing behavior. I also added strict validation so this .9000 path is only applied in the R-package flow, plus edge-case tests for invalid versions.

@kelly-sovacool kelly-sovacool left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This package imports version-related functions from CCBR/Tools: https://github.com/CCBR/Tools/blob/main/src/ccbr_tools/versions.py

Many of those functions expect strict semantic versions.
Determine what modifications will need to be made, whether in this package or in CCBR/Tools, to accommodate R's special version format.

Copilot AI and others added 2 commits May 6, 2026 22:55
Agent-Logs-Url: https://github.com/CCBR/actions/sessions/9b00b850-fcff-4b5f-ac0b-8facbc245bd1

Co-authored-by: kelly-sovacool <17768269+kelly-sovacool@users.noreply.github.com>
Agent-Logs-Url: https://github.com/CCBR/actions/sessions/9b00b850-fcff-4b5f-ac0b-8facbc245bd1

Co-authored-by: kelly-sovacool <17768269+kelly-sovacool@users.noreply.github.com>

Copilot AI commented May 6, 2026

Copy link
Copy Markdown
Contributor Author

This package imports version-related functions from CCBR/Tools: https://github.com/CCBR/Tools/blob/main/src/ccbr_tools/versions.py

Many of those functions expect strict semantic versions....

I audited this and added a safeguard in this repo in a0752a1 (plus tests in 0082271): get_release_version() now enforces full-string semver before calling ccbr_tools.versions.check_version_increments_by_one, so tags like v1.2.3.9000 are rejected as release tags. R’s special .9000 format remains supported only for DESCRIPTION post-release dev bumps.

What this implies: no immediate CCBR/Tools change is required for this PR, but an upstream improvement in CCBR/Tools would be to add an optional full-match mode (or switch match_semver to fullmatch semantics) so consumers don’t need to add this guard themselves.

@codecov

codecov Bot commented May 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.56%. Comparing base (208391b) to head (c8e8a8c).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #170      +/-   ##
==========================================
+ Coverage   89.34%   93.56%   +4.21%     
==========================================
  Files          11       11              
  Lines         460      544      +84     
==========================================
+ Hits          411      509      +98     
+ Misses         49       35      -14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kelly-sovacool kelly-sovacool left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agent-Logs-Url: https://github.com/CCBR/actions/sessions/f39f3c97-4536-4c84-b91f-7b705d9c5cbe

Co-authored-by: kelly-sovacool <17768269+kelly-sovacool@users.noreply.github.com>
Agent-Logs-Url: https://github.com/CCBR/actions/sessions/f39f3c97-4536-4c84-b91f-7b705d9c5cbe

Co-authored-by: kelly-sovacool <17768269+kelly-sovacool@users.noreply.github.com>

Copilot AI commented May 7, 2026

Copy link
Copy Markdown
Contributor Author

Add unit tests to cover the missed lines: https://app.codecov.io/gh/CCBR/actions/pull/170?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=CCB...

Added in 8a0ae43: I expanded tests/test_release.py with focused unit tests for the previously missed release branches (including NEWS path selection, DESCRIPTION Version-field error/update paths, non-debug helper execution paths, and workflow-trigger warning handling). Local coverage for ccbr_actions.release is now 100% with python -m pytest tests/test_release.py --cov=ccbr_actions.release --cov-report=term-missing. No UI changes in this update.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds first-class R package support to the repository’s release automation so draft-release and post-release can operate on R package conventions (NEWS*, DESCRIPTION, and CITATION.cff) while also tightening release-tag semver validation.

Changes:

  • Introduces R package detection and switches default release file targets from CHANGELOG.md/VERSION to NEWS*/DESCRIPTION (including R-style .9000 dev version bump post-release).
  • Regenerates CITATION.cff from DESCRIPTION via cffr for R package repos and wires conditional R setup into the composite actions.
  • Hardens release tag parsing by enforcing full-string semver validation and adds focused tests for the new behavior.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/ccbr_actions/release.py Adds R package detection, DESCRIPTION version writing, citation regeneration via R/cffr, and strict semver validation.
tests/test_release.py Expands unit coverage for R package flows, .9000 versioning, NEWS selection, and strict semver rejection cases.
draft-release/action.yml Adds description-filepath input, conditionally sets up R/cffr, and passes DESCRIPTION path into the Python release helper.
draft-release/README.md Documents the new description-filepath input for R package detection/behavior.
post-release/action.yml Adds description-filepath input, conditionally sets up R/cffr, and passes DESCRIPTION path into post-release cleanup.
post-release/README.md Documents the new description-filepath input for R package detection/behavior.

Comment thread src/ccbr_actions/release.py Outdated
Comment on lines +91 to +113
def regenerate_citation_from_description(citation_filepath="CITATION.cff", debug=False):
"""
Regenerate CITATION.cff from DESCRIPTION using cffr.

Args:
citation_filepath (str): Path to output CITATION.cff.
debug (bool): If True, print command instead of running it.
"""
r_expression = (
'if (!requireNamespace("cffr", quietly = TRUE)) '
'stop("Missing required R package: cffr. Install it in workflow setup (e.g. setup-r-dependencies)."); '
'cffr::cff_write(cff_file = Sys.getenv("CITATION_FILE"))'
)
citation_filepath_quoted = shlex.quote(str(citation_filepath))
cmd = (
f"CITATION_FILE={citation_filepath_quoted} "
f"Rscript -e {shlex.quote(r_expression)}"
)
if debug:
print(cmd)
else:
shell_run(cmd)

@kelly-sovacool kelly-sovacool changed the title Add R package-aware release handling to draft-release and post-release actions feat: add R package-aware release handling to draft-release and post-release actions May 21, 2026
@kelly-sovacool

Copy link
Copy Markdown
Member

To-Do @kelly-sovacool: test this by running these workflows from a sandbox repo

@kelly-sovacool kelly-sovacool added this to the 2026-06 milestone May 21, 2026
@kelly-sovacool

Copy link
Copy Markdown
Member

@copilot edit the changelog with a one-line description of this PR. Link the PR number and tag both of us as authors.

Agent-Logs-Url: https://github.com/CCBR/actions/sessions/bb8d7c15-72c4-4f93-923a-d39661457387

Co-authored-by: kelly-sovacool <17768269+kelly-sovacool@users.noreply.github.com>
Agent-Logs-Url: https://github.com/CCBR/actions/sessions/ecbbdbf4-a2fe-4aa1-a55f-287f3681d59f

Co-authored-by: kelly-sovacool <17768269+kelly-sovacool@users.noreply.github.com>

Copilot AI commented May 21, 2026

Copy link
Copy Markdown
Contributor Author

@copilot edit the changelog with a one-line description of this PR. Link the PR number and tag both of us as authors.

Updated in abb26e0: added a one-line changelog entry under actions development version with PR reference #170 and both author tags @kelly-sovacool and @copilot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

support R package structure in draft-release & post-release

3 participants