-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (70 loc) · 2.32 KB
/
Copy pathversion_update.yml
File metadata and controls
85 lines (70 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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}"