rmarkdown language and assert for dbetabinom #24
Workflow file for this run
This file contains 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: Version bump ⬆ | ||
on: | ||
push: | ||
branches: | ||
- main | ||
- pre-release | ||
workflow_dispatch: | ||
workflow_call: | ||
secrets: | ||
GITHUB_TOKEN: | ||
description: Github token with write access to the repo | ||
required: false | ||
concurrency: | ||
group: vbump-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
jobs: | ||
vbump: | ||
name: Bump version ⤴ | ||
runs-on: ubuntu-latest | ||
if: | | ||
!( contains(github.event.commits[0].message, '[skip vbump]') || | ||
contains(github.event.head_commit.message, '[skip vbump]') | ||
) | ||
container: | ||
image: docker.io/rocker/tidyverse:4.2.1 | ||
steps: | ||
- name: Checkout repo 🛎 | ||
uses: actions/checkout@v3 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Bump version in DESCRIPTION (main) 📜 | ||
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} | ||
run: desc::desc_bump_version("dev", normalize = TRUE) | ||
shell: Rscript {0} | ||
- name: Bump version in DESCRIPTION (pre-release) 📜 | ||
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/pre-release' }} | ||
run: desc::desc_bump_version(5, normalize = TRUE) | ||
shell: Rscript {0} | ||
- name: Remove ending .0 version | ||
run: | | ||
get_version_components <- function(x) { | ||
as.numeric(strsplit(format(x), "[-\\.]")[[1]]) | ||
} | ||
ver_str <- desc::desc_get_version() | ||
ver <- get_version_components(ver_str) | ||
if (length(ver) > 3) desc::desc_set_version(gsub("[.]0$", "", ver_str)) | ||
shell: Rscript {0} | ||
- name: Bump version in NEWS.md 📰 | ||
run: | | ||
git config --global --add safe.directory $(pwd) | ||
DESC_VERSION=$(R --slave -e 'cat(paste(desc::desc_get_version()))') | ||
NEWS_VERSION=$(awk '/^#+ /{print $3; exit}' NEWS.md) | ||
sed -i "s/$NEWS_VERSION/$DESC_VERSION/" NEWS.md | ||
NEWS_VERSION=$(awk '/^#+ /{print $3; exit}' NEWS.md) | ||
echo "Updated NEWS.md version: $NEWS_VERSION" | ||
if (test $DESC_VERSION != $NEWS_VERSION ); then | ||
echo "🙈 Updated NEWS.md and DESCRIPTION have different versions!" | ||
echo "Please ensure that the versions in the NEWS.md and DESCRIPTION are the same 🙏" | ||
exit 1 | ||
fi | ||
echo "NEW_PKG_VERSION=${DESC_VERSION}" >> $GITHUB_ENV | ||
shell: bash | ||
- name: Commit and push changes 📌 | ||
if: ${{ env.NEW_PKG_VERSION }} | ||
uses: stefanzweifel/git-auto-commit-action@v4 | ||
with: | ||
commit_message: "[skip actions] Bump version to ${{ env.NEW_PKG_VERSION }}" | ||
file_pattern: NEWS.md DESCRIPTION | ||
commit_user_name: github-actions | ||
commit_user_email: >- | ||
41898282+github-actions[bot]@users.noreply.github.com |