-
Notifications
You must be signed in to change notification settings - Fork 1
53 lines (45 loc) · 1.7 KB
/
version-check.yml
File metadata and controls
53 lines (45 loc) · 1.7 KB
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
name: Version Check
on:
pull_request:
branches:
- master
paths:
- 'package.json'
jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Checkout PR
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check version change
id: version-check
run: |
# Get version from PR
PR_VERSION=$(node -p "require('./package.json').version")
# Get version from master
git fetch origin master
git checkout origin/master -- package.json
MASTER_VERSION=$(node -p "require('./package.json').version")
git checkout HEAD -- package.json
echo "Master version: $MASTER_VERSION"
echo "PR version: $PR_VERSION"
if [ "$PR_VERSION" != "$MASTER_VERSION" ]; then
echo "::error::❌ Do not manually change version in package.json!"
echo "::error::Use 'workflow_dispatch' on Publish workflow to bump versions automatically."
echo "::error::Master: $MASTER_VERSION -> PR: $PR_VERSION"
exit 1
fi
echo "✅ Version check passed!"
- name: Comment on PR
if: failure()
uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '❌ **Version Change Detected**\n\nPlease do not manually change the version in `package.json`.\n\nUse the **[Publish to NPM](../../actions/workflows/publish.yml)** workflow to automatically bump versions.'
})