-
Notifications
You must be signed in to change notification settings - Fork 175
38 lines (38 loc) · 1.43 KB
/
semver-on-release-labeled-pr.yml
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
name: Check Semver for Pull Request
on:
pull_request:
branches: [master]
types: [labeled, unlabeled, opened, synchronize]
jobs:
verify-version:
if: contains(github.event.pull_request.labels.*.name, 'release')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Get Pull Request Version
id: pr-version
run: echo "version=$(jq -r .version package.json)" >> $GITHUB_OUTPUT
- uses: actions/checkout@v3
with:
ref: master
- name: Get Base Version
id: base-version
run: echo "version=$(jq -r .version package.json)" >> $GITHUB_OUTPUT
- uses: actions/setup-node@v3
with:
node-version: 16
- run: yarn add semver
- uses: actions/github-script@v6
env:
PR_VERSION: ${{steps.pr-version.outputs.version}}
BASE_VERSION: ${{steps.base-version.outputs.version}}
with:
script: |
const semver = require("semver")
const { PR_VERSION: pr, BASE_VERSION: base } = process.env
const pr_is_greater = semver.gt(pr, base)
if (pr_is_greater) {
core.debug(`Success, the pr version (${pr}) is higher than the base version (${base}).`)
} else {
core.setFailed(`The pr version (${pr}) is not greater than the base version (${base}). A pull request labeled with 'release' must have a valid version bump.`)
}