CI: use central d-morrison/gha check-news reusable workflow #1669
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
| --- | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened, labeled, unlabeled] | |
| branches: | |
| - main | |
| name: Version increment check | |
| jobs: | |
| version-check: | |
| if: ${{ github.event_name == 'pull_request' }} | |
| runs-on: ubuntu-latest | |
| env: | |
| GITHUB_PAT: ${{ github.token }} | |
| permissions: | |
| pull-requests: read | |
| steps: | |
| - name: Check if version increment is required | |
| id: check_label | |
| run: | | |
| if [[ '${{ contains(github.event.pull_request.labels.*.name, 'no version increment') }}' == 'true' ]]; then | |
| echo "Version increment not required (label present)" | |
| echo "skip=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "Version increment required (label not present)" | |
| echo "skip=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: checkout working HEAD | |
| if: steps.check_label.outputs.skip != 'true' | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.pull_request.head.ref }} | |
| sparse-checkout: | | |
| DESCRIPTION | |
| path: working | |
| - name: checkout base HEAD | |
| if: steps.check_label.outputs.skip != 'true' | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.pull_request.base.ref }} | |
| sparse-checkout: | | |
| DESCRIPTION | |
| path: compare | |
| - name: show files | |
| if: steps.check_label.outputs.skip != 'true' | |
| run: | | |
| ls -lR working compare | |
| echo "\nWORKING:\n" | |
| cat working/DESCRIPTION | |
| echo "\nCOMPARE:\n" | |
| cat compare/DESCRIPTION | |
| - name: Setup R | |
| if: steps.check_label.outputs.skip != 'true' | |
| uses: r-lib/actions/setup-r@v2 | |
| with: | |
| use-public-rspm: true | |
| - name: compare versions | |
| if: steps.check_label.outputs.skip != 'true' | |
| run: | | |
| Rscript -e " \ | |
| install.packages('desc'); \ | |
| working_version <- desc::desc_get_version('working/DESCRIPTION'); \ | |
| message('PR branch version: ', working_version); \ | |
| compare_version <- desc::desc_get_version('compare/DESCRIPTION'); \ | |
| message('main branch version: ', compare_version); \ | |
| stopifnot(working_version > compare_version); \ | |
| " |