-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* redo semver check manually
- Loading branch information
Showing
2 changed files
with
38 additions
and
16 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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: npm install 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.`) | ||
} |