File tree Expand file tree Collapse file tree 2 files changed +46
-7
lines changed
Expand file tree Collapse file tree 2 files changed +46
-7
lines changed Original file line number Diff line number Diff line change 1+ name : Check Version update on release
2+
3+ on :
4+ pull_request :
5+ branches :
6+ - ' release/*'
7+
8+ jobs :
9+ check :
10+ runs-on : ubuntu-latest
11+ steps :
12+ - uses : actions/checkout@v5
13+ with :
14+ fetch-depth : 0
15+
16+ - run : |
17+ CHANGED_FILES=$(git diff --name-only "origin/${{ github.base_ref }}...HEAD")
18+
19+ if ! echo "${CHANGED_FILES}" | grep -qx "package.json"; then
20+ echo "::error::Release PRs must include an update to package.json."
21+ exit 1
22+ fi
23+
24+ if ! echo "${CHANGED_FILES}" | grep -qx "package-lock.json"; then
25+ echo "::error::Release PRs must include an update to package-lock.json."
26+ exit 1
27+ fi
Original file line number Diff line number Diff line change 44 push :
55 branches :
66 - main
7- tags :
8- - ' v*'
97 pull_request :
108 branches :
119 - main
@@ -77,25 +75,39 @@ jobs:
7775 path : coverage
7876
7977 publish :
80- name : Publish
78+ if : github.event_name == 'push' && github.ref == 'refs/heads/main'
79+ name : Publish on version update
8180 needs :
8281 - test
8382 permissions :
8483 contents : read
8584 id-token : write
8685 runs-on : ubuntu-latest
87- if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
8886 steps :
8987 - uses : actions/checkout@v5
9088 - uses : actions/setup-node@v5
9189 with :
9290 node-version-file : ' /.nvmrc'
9391 registry-url : ' https://registry.npmjs.org'
9492
95- - run : npm ci
96- - run : npm run build
93+ - name : Check for version update
94+ id : check_version
95+ run : |
96+ CURRENT_VERSION=$(jq -r .version package.json)
97+ PREVIOUS_VERSION=$(git show HEAD~1:package.json | jq -r .version)
98+
99+ if [[ "$CURRENT_VERSION" != "$PREVIOUS_VERSION" ]]; then
100+ echo "version_updated=true" >> $GITHUB_OUTPUT
101+ fi
102+
103+ - if : steps.check_version.outputs.version_updated
104+ run : npm ci
105+
106+ - if : steps.check_version.outputs.version_updated
107+ run : npm run build
97108
98- - name : Publish
109+ - if : steps.check_version.outputs.version_updated
110+ name : Publish
99111 env :
100112 NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
101113 run : |
You can’t perform that action at this time.
0 commit comments