Skip to content

remove pedant in Suggests #10

remove pedant in Suggests

remove pedant in Suggests #10

# Generated by rpkgkit::use_workflow_version_update()
name: Update R Package Version
on:
push:
branches: [main, master]
# Allow manual trigger with version type override
workflow_dispatch:
inputs:
version_type:
description: "Version bump type (major / minor / patch)"
required: false
default: "patch"
type: choice
options:
- major
- minor
- patch
custom_version:
description: "Custom version (e.g. 1.2.3, overrides version_type)"
required: false
type: string
permissions:
contents: write
jobs:
update-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true
- name: Install desc package
run: Rscript -e 'install.packages(c("desc", "rlang"))'
- name: Configure Git user
run: |
git config user.name "github-actions"
git config user.email "github-actions@github.com"
- name: Pull latest changes
if: steps.version_bump.outputs.type != 'none'
run: |
git fetch origin
git pull --rebase origin "${{ github.ref_name }}"
- name: Determine version bump type
id: version_bump
run: |
# Priority: custom_version > version_type input > commit message
CUSTOM_VERSION="${{ github.event.inputs.custom_version }}"
INPUT_TYPE="${{ github.event.inputs.version_type }}"
if [ -n "$CUSTOM_VERSION" ]; then
echo "type=custom" >> "$GITHUB_OUTPUT"
echo "custom_version=$CUSTOM_VERSION" >> "$GITHUB_OUTPUT"
exit 0
fi
if [ -n "$INPUT_TYPE" ]; then
echo "type=$INPUT_TYPE" >> "$GITHUB_OUTPUT"
exit 0
fi
# Infer from commit message
COMMIT_MSG=$(git log -1 --pretty=%B | tr "[:upper:]" "[:lower:]")
if echo "$COMMIT_MSG" | grep -qE "\<(major|breaking)\!\>|\<(major|breaking)\>"; then
echo "type=major" >> "$GITHUB_OUTPUT"
elif echo "$COMMIT_MSG" | grep -qE "\<(feat|feature|minor)\!\>|\<(feat|feature|minor)\>"; then
echo "type=minor" >> "$GITHUB_OUTPUT"
elif echo "$COMMIT_MSG" | grep -qE "\<(fix|patch|bug)\!\>|\<(fix|patch|bug)\>"; then
echo "type=patch" >> "$GITHUB_OUTPUT"
else
echo "type=none" >> "$GITHUB_OUTPUT"
fi
- name: Bump version in DESCRIPTION
id: update_version
if: steps.version_bump.outputs.type != 'none'
run: |
TYPE="${{ steps.version_bump.outputs.type }}"
CUSTOM="${{ steps.version_bump.outputs.custom_version }}"
CURRENT_VERSION=$(Rscript -e "cat(as.character(desc::desc_get_version()))")
echo "Current version: $CURRENT_VERSION"
if [ "$TYPE" = "custom" ] && [ -n "$CUSTOM" ]; then
NEW_VERSION="$CUSTOM"
elif [ "$TYPE" = "major" ]; then
NEW_VERSION=$(Rscript -e \
"v <- as.character(desc::desc_get_version());
parts <- as.integer(unlist(strsplit(v, '\\\\.')));
parts[1] <- parts[1] + 1L; parts[2] <- 0L; parts[3] <- 0L;
cat(paste(parts, collapse = '.'))")
elif [ "$TYPE" = "minor" ]; then
NEW_VERSION=$(Rscript -e \
"v <- as.character(desc::desc_get_version());
parts <- as.integer(unlist(strsplit(v, '\\\\.')));
parts[2] <- parts[2] + 1L; parts[3] <- 0L;
cat(paste(parts, collapse = '.'))")
elif [ "$TYPE" = "patch" ]; then
NEW_VERSION=$(Rscript -e \
"v <- as.character(desc::desc_get_version());
parts <- as.integer(unlist(strsplit(v, '\\\\.')));
parts[3] <- parts[3] + 1L;
cat(paste(parts, collapse = '.'))")
else
echo "Unknown type: $TYPE"
exit 1
fi
echo "New version: $NEW_VERSION"
Rscript -e "desc::desc_set_version('$NEW_VERSION')"
echo "NEW_VERSION=$NEW_VERSION" >> "$GITHUB_ENV"
- name: Update version badge in README
if: steps.version_bump.outputs.type != 'none'
run: |
for f in README.md README.Rmd; do
if [ -f "$f" ]; then
sed -i "s|\(badge/devel%20version-\)[0-9]\+\.[0-9]\+\.[0-9]\+|\1$NEW_VERSION|g" "$f"
echo "Updated $f badge"
fi
done
- name: Commit and tag
if: steps.version_bump.outputs.type != 'none'
run: |
git add DESCRIPTION README.md 2>/dev/null || true
if [ -f README.Rmd ]; then
git add README.Rmd
fi
if git diff --staged --quiet; then
echo "No changes to commit."
exit 0
fi
git commit -m "chore: bump version to $NEW_VERSION [skip ci]"
if git rev-parse "v$NEW_VERSION" >/dev/null 2>&1; then
echo "Tag v$NEW_VERSION already exists, skipping."
else
git tag -a "v$NEW_VERSION" -m "Version $NEW_VERSION"
fi
- name: Push changes
if: steps.version_bump.outputs.type != 'none'
run: |
git push origin "${{ github.ref_name }}"
TAG="v$NEW_VERSION"
if git rev-parse "$TAG" >/dev/null 2>&1; then
git push origin "$TAG"
fi