A week ago, I shared an experimental workflow for automating CRAN submissions through GitHub Actions. Today, I’m excited to announce that this experiment has evolved into a proper, reusable GitHub Action that any R package developer can incorporate into their workflow with minimal setup.
What makes this Action “proper”?
The new R Package CRAN Submission GitHub Action improves upon the experimental workflow in several key ways:
- Simplified integration - Add the action with a single reference in your workflow file
- Flexible triggers - Run on pre-releases or via manual workflow dispatch with confirmation
- Better debugging - Clear parameter reporting helps diagnose any issues
- Customizable options - Configure the action to suit your package’s needs
How to Use the GitHub Action
Adding the action to your repository is straightforward:
name: Submit to CRAN
on:
release:
types: [prereleased]
jobs:
cran-submission:
runs-on: ubuntu-latest
name: Submit package to CRAN
permissions:
contents: read
issues: write # Needed to create issues
steps:
- uses: actions/checkout@v4
- name: Submit R package to CRAN
uses: yourusername/r-package-cran-submission-action@v1
with:
pkg-directory: '.' # Directory containing the package
check-directory: 'check' # Directory for check outputs
error-on: 'warning' # Fail on warnings
create-issue: true # Create issues to track submissions
This workflow file will trigger the action whenever a pre-release is created.
If you would like to trigger the action manually, you can include the following within the on
key.
on:
# Allow manual triggering with confirmation
workflow_dispatch:
inputs:
confirmation:
description: 'Type "CONFIRM" to proceed with CRAN submission'
required: true
default: ''
type: string
The confirmation
input requires you to type “CONFIRM” to proceed with the CRAN submission. This is a safety measure to prevent accidental submissions.
Safety First: Preventing Accidental Submissions
The action includes several safeguards to prevent unintended CRAN submissions:
- Pre-release Only - For release events, it only runs on pre-releases, not full releases
- Manual Confirmation - When triggered manually, requires typing “CONFIRM” to proceed
- R CMD Check - Automatically fails if your package has warnings or errors
- Email Notification - Creates a GitHub issue reminding you to check for the CRAN confirmation email
From Experimental to Production-Ready
In the previous post, I outlined the experimental approach that required copying workflow files to your repository. The new GitHub Action eliminates this complexity:
- Before: Copy multiple workflow files and script files to your repository
- Now: Reference the action with a single line in your workflow file
All the safety checks, validation logic, and submission handling are now encapsulated in the action itself, making it more maintainable and easier to update when improvements are made.
Fin
The R Package CRAN Submission GitHub Action represents a significant step forward in automating the CRAN submission process for R packages. By converting our experimental workflow into a proper GitHub Action, we’ve made it more accessible, safer, and easier to integrate into your development workflow.
Try it out in your next package release and let me know what you think! Contributions and feedback are welcome on the GitHub repository.