-
Notifications
You must be signed in to change notification settings - Fork 1
61 lines (51 loc) · 1.93 KB
/
check_version.yaml
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
name: Check Version Bump
on:
pull_request:
branches:
- devel
jobs:
check-version:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libcurl4-openssl-dev libssl-dev
- name: Setup R
uses: r-lib/actions/setup-r@v2
- name: Install R dependencies
run: Rscript -e 'install.packages(c("devtools", "usethis", "desc"), repos = "http://cran.rstudio.com/")'
- name: Get current version
id: get_current_version
run: echo "::set-output name=current_version::$(grep Version DESCRIPTION | cut -d' ' -f2)"
- name: Get previous version from main branch
run: |
git fetch origin main
git checkout origin/main -- DESCRIPTION
echo "::set-output name=previous_version::$(grep Version DESCRIPTION | cut -d' ' -f2)"
id: get_previous_version
- name: Compare versions
run: |
echo "Current version: ${{ steps.get_current_version.outputs.current_version }}"
echo "Previous version: ${{ steps.get_previous_version.outputs.previous_version }}"
if [[ "${{ steps.get_current_version.outputs.current_version }}" == "${{ steps.get_previous_version.outputs.previous_version }}" ]]; then
echo "Version has not been changed."
exit 1
else
echo "Version has been changed."
fi
- name: Add comment if version not changed
if: failure()
uses: actions/github-script@v4
with:
script: |
github.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: 'The version of the package in the DESCRIPTION file has not been changed. Please update the version.'
})
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}