Skip to content

Commit 5ca94f8

Browse files
authoredFeb 13, 2025··
Merge pull request #230 from pharmaverse/209-remove-dev-branch-and-use-usethisversion
Closes #209 new version who this?
2 parents f6c24f8 + a4b72f4 commit 5ca94f8

File tree

6 files changed

+168
-3
lines changed

6 files changed

+168
-3
lines changed
 

‎.github/pull_request_template.md

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ logrx is built around the concept of creating a log for the execution of an R sc
1111
Please check off each taskbox as an acknowledgment that you completed the task. This checklist is part of the Github Action workflows and the Pull Request will not be merged into the `dev` branch until you have checked off each task.
1212

1313
- [ ] The spirit of logrx is met in your Pull Request
14-
- [ ] Check that your Pull Request is targeting the dev branch, Pull Requests to master should use the [Release Pull Request Template](https://github.com/pharmaverse/logrx/blob/main/.github/PULL_REQUEST_TEMPLATE/release.md)
1514
- [ ] Code is formatted according to the [tidyverse style guide](https://style.tidyverse.org/)
1615
- [ ] Updated relevant unit tests or have written new unit tests. Remember to remove any configured log objects at the end of every test using `log_remove()`.
1716
- [ ] Creation/updates to relevant roxygen headers and examples.

‎.github/workflows/version-bump.yaml

+159
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
---
2+
name: Version bump ⬆
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
workflow_dispatch:
9+
workflow_call:
10+
secrets:
11+
REPO_GITHUB_TOKEN:
12+
description: Github token with write access to the repo
13+
required: false
14+
inputs:
15+
disable-precommit-autoupdate:
16+
description: Disable precommit autoupdate
17+
required: false
18+
default: false
19+
type: boolean
20+
vbump-after-release:
21+
description: Whether the vbump workflow is running after a release has been published
22+
required: false
23+
default: false
24+
type: boolean
25+
package-subdirectory:
26+
description: Subdirectory in the repository, where the R package is located.
27+
required: false
28+
type: string
29+
default: "."
30+
31+
concurrency:
32+
group: vbump-${{ github.event.pull_request.number || github.ref }}
33+
cancel-in-progress: true
34+
35+
jobs:
36+
vbump:
37+
name: Bump version ⤴
38+
runs-on: ubuntu-latest
39+
if: |
40+
!(contains(github.event.commits[0].message, '[skip vbump]') ||
41+
contains(github.event.head_commit.message, '[skip vbump]')
42+
)
43+
container:
44+
image: docker.io/rocker/tidyverse:latest
45+
46+
steps:
47+
- name: Setup token 🔑
48+
id: github-token
49+
run: |
50+
if [ "${{ secrets.REPO_GITHUB_TOKEN }}" == "" ]; then
51+
echo "REPO_GITHUB_TOKEN is empty. Substituting it with GITHUB_TOKEN."
52+
echo "token=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_OUTPUT
53+
else
54+
echo "Using REPO_GITHUB_TOKEN."
55+
echo "token=${{ secrets.REPO_GITHUB_TOKEN }}" >> $GITHUB_OUTPUT
56+
fi
57+
shell: bash
58+
59+
- name: Get branch names 🌿
60+
id: branch-name
61+
uses: tj-actions/branch-names@v7
62+
63+
- name: Checkout repo 🛎
64+
uses: actions/checkout@v4.1.1
65+
with:
66+
ref: ${{ steps.branch-name.outputs.head_ref_branch }}
67+
token: ${{ steps.github-token.outputs.token }}
68+
69+
- name: Bump version in DESCRIPTION 📜
70+
if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') || inputs.vbump-after-release == true }}
71+
run: desc::desc_bump_version("dev", normalize = TRUE)
72+
shell: Rscript {0}
73+
working-directory: ${{ inputs.package-subdirectory }}
74+
75+
- name: Update Date field 📅
76+
run: if (desc::desc_has_fields("Date")) desc::desc_set("Date", Sys.Date())
77+
shell: Rscript {0}
78+
working-directory: ${{ inputs.package-subdirectory }}
79+
80+
- name: Bump version in NEWS.md 📰
81+
run: |
82+
if [ -f NEWS.md ]
83+
then {
84+
git config --global --add safe.directory $(pwd)
85+
DESC_VERSION=$(R --slave -e 'cat(paste(desc::desc_get_version()))' | tr -d '\n' | xargs)
86+
NEWS_VERSION=$(awk '/^#+ /{print $3,$4; exit}' NEWS.md | tr -d '\n' | xargs)
87+
FIRST_NEWS_LINE=$(head -1 NEWS.md)
88+
if [ "${{ inputs.vbump-after-release }}" == "true" ]; then
89+
# Add a new section with the released version that will be vbumped below.
90+
printf "$FIRST_NEWS_LINE\n\n" | cat - NEWS.md > temp-news.md
91+
mv temp-news.md NEWS.md
92+
fi
93+
# Replace only the first occurence of $NEWS_VERSION,
94+
# but only if it's not already set to (development version)
95+
if [ $NEWS_VERSION != "(development version)" ]
96+
then {
97+
sed -i "0,/$NEWS_VERSION/s/$NEWS_VERSION/$DESC_VERSION/" NEWS.md
98+
}
99+
fi
100+
echo "NEW_PKG_VERSION=${DESC_VERSION}" >> $GITHUB_ENV
101+
}
102+
fi
103+
shell: bash
104+
working-directory: ${{ inputs.package-subdirectory }}
105+
106+
- name: Check if a pre-commit config exists
107+
id: precommit-config-exists
108+
uses: andstor/file-existence-action@v3
109+
with:
110+
files: ".pre-commit-config.yaml"
111+
112+
- name: Setup Python 🐍
113+
if: |
114+
inputs.disable-precommit-autoupdate != 'true' &&
115+
steps.precommit-config-exists.outputs.files_exists == 'true'
116+
uses: actions/setup-python@v5
117+
with:
118+
python-version: '3.12'
119+
120+
- name: Precommit autoupdate 🅿️
121+
if: |
122+
inputs.disable-precommit-autoupdate != 'true' &&
123+
steps.precommit-config-exists.outputs.files_exists == 'true'
124+
run: |
125+
git config --global --add safe.directory $(pwd)
126+
python -m pip -q install pre-commit
127+
pre-commit autoupdate
128+
129+
- name: Checkout to main 🛎
130+
if: ${{ inputs.vbump-after-release == true }}
131+
run: |
132+
git fetch origin main
133+
git checkout main
134+
git pull origin main
135+
136+
- name: Set file pattern to commit ⚙️
137+
id: file-pattern
138+
run: |
139+
if [[ "${{ inputs.package-subdirectory }}" == "." || "${{ inputs.package-subdirectory }}" == "" ]]; then
140+
FILE_PATTERN="NEWS.md DESCRIPTION"
141+
else
142+
FILE_PATTERN="${{ inputs.package-subdirectory }}/NEWS.md ${{ inputs.package-subdirectory }}/DESCRIPTION"
143+
fi
144+
if [[ '${{ steps.precommit-config-exists.outputs.files_exists }}' == 'true' ]]; then
145+
FILE_PATTERN="$FILE_PATTERN .pre-commit-config.yaml"
146+
fi
147+
echo "file-pattern=$FILE_PATTERN" >> $GITHUB_OUTPUT
148+
shell: bash
149+
150+
- name: Commit and push changes 📌
151+
if: ${{ env.NEW_PKG_VERSION }}
152+
uses: stefanzweifel/git-auto-commit-action@v5
153+
with:
154+
commit_message: "[skip actions] Bump version to ${{ env.NEW_PKG_VERSION }}"
155+
file_pattern: "${{ steps.file-pattern.outputs.file-pattern }}"
156+
commit_user_name: github-actions
157+
commit_user_email: >-
158+
41898282+github-actions[bot]@users.noreply.github.com
159+
continue-on-error: true

‎DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: logrx
22
Title: A Logging Utility Focus on Clinical Trial Programming Workflows
3-
Version: 0.3.1
3+
Version: 0.3.1.9000
44
Authors@R:
55
c(
66
person(given = "Nathan",

‎NEWS.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# logrx (development version)
2+
3+
- Items go here with issue number - remove this later (#209)
14

25
# logrx 0.3.1
36

‎README.Rmd

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ install.packages("logrx")
3636
To get the latest development version use:
3737

3838
```{r, eval = FALSE}
39-
devtools::install_github("pharmaverse/logrx", ref = "dev")
39+
devtools::install_github("pharmaverse/logrx")
4040
```
4141

4242
## What is ```{logrx}``` ?

‎_pkgdown.yml

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ search:
99
news:
1010
cran_dates: true
1111

12+
development:
13+
mode: auto
14+
version_label: default
15+
1216
navbar:
1317
structure:
1418
right: [slack, github]

0 commit comments

Comments
 (0)
Please sign in to comment.