update #19
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Update R Package Version | |
| on: | |
| push: | |
| branches: [main, master] | |
| workflow_dispatch: | |
| inputs: | |
| version_type: | |
| description: "Version bump type" | |
| required: false | |
| default: "patch" | |
| type: choice | |
| options: [major, minor, patch, custom] | |
| custom_version: | |
| description: "Custom version (e.g. 1.2.3)" | |
| required: false | |
| type: string | |
| permissions: | |
| contents: write | |
| concurrency: | |
| group: version-update-${{ github.ref }} | |
| cancel-in-progress: false | |
| jobs: | |
| update-version: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup R | |
| uses: r-lib/actions/setup-r@v2 | |
| with: | |
| use-public-rspm: true | |
| - name: Install desc | |
| run: Rscript -e "install.packages('desc')" | |
| - name: Configure Git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Bump version | |
| id: version_bump | |
| uses: ./.github/actions/version-bumper | |
| with: | |
| version_type: ${{ github.event.inputs.version_type || 'patch' }} | |
| custom_version: ${{ github.event.inputs.custom_version }} | |
| - name: Update README badges | |
| if: steps.version_bump.outputs.bumped == 'true' | |
| run: | | |
| NEW_VER="${{ steps.version_bump.outputs.new_version }}" | |
| for file in README.md README.Rmd; do | |
| if [ -f "$file" ]; then | |
| sed -i "s|\\(badge/devel%20version-\\)[0-9]\\+\\.[0-9]\\+\\.[0-9]\\+|\\1${NEW_VER}|g" "$file" | |
| echo "✅ Updated $file" | |
| fi | |
| done | |
| - name: Commit and tag | |
| if: steps.version_bump.outputs.bumped == 'true' | |
| run: | | |
| git add DESCRIPTION README.md README.Rmd 2>/dev/null || true | |
| if git diff --staged --quiet; then | |
| echo "No changes to commit" | |
| exit 0 | |
| fi | |
| NEW_VER="${{ steps.version_bump.outputs.new_version }}" | |
| git commit -m "chore: bump version to ${NEW_VER} [skip ci]" | |
| git tag -a "v${NEW_VER}" -m "Release v${NEW_VER}" | |
| git push origin "${{ github.ref_name }}" | |
| git push origin "v${NEW_VER}" | |
| echo "🎉 Released v${NEW_VER}" |