Skip to content

Commit 1d3c59f

Browse files
ci: replace npx changelog call with npm script and fix prepare-release workflow
1 parent 5f7133f commit 1d3c59f

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

‎.github/workflows/prepare-release.yml‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,14 @@ jobs:
3838
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3939
run: |
4040
# Run semantic-release with dry-run to detect version
41-
NEXT_VERSION=$(npx semantic-release --dry-run --verify-conditions false | tee /dev/stderr | awk '/The next release version is/{print $NF}')
41+
set -o pipefail
42+
if ! OUTPUT=$(npx semantic-release --dry-run --verify-conditions false --verify-release false 2>&1); then
43+
echo "$OUTPUT"
44+
echo "::error::semantic-release failed during version detection"
45+
exit 1
46+
fi
47+
echo "$OUTPUT"
48+
NEXT_VERSION=$(echo "$OUTPUT" | awk '/The next release version is/{print $NF}')
4249
echo "next=$NEXT_VERSION" >> $GITHUB_OUTPUT
4350
4451
- name: Update package.json
@@ -49,7 +56,7 @@ jobs:
4956

5057
- name: Update CHANGELOG.md
5158
if: steps.version.outputs.next != ''
52-
run: npx conventional-changelog-cli -p conventionalcommits -i CHANGELOG.md -s
59+
run: npm run update-changelog
5360

5461
- name: Create Pull Request
5562
if: steps.version.outputs.next != ''

‎package.json‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
},
99
"scripts": {
1010
"test": "make test",
11-
"prepare": "husky"
11+
"prepare": "husky",
12+
"update-changelog": "conventional-changelog -p conventionalcommits -i CHANGELOG.md"
1213
},
1314
"files": [
1415
"index.js",
@@ -39,6 +40,7 @@
3940
"@commitlint/cli": "^20.3.1",
4041
"@commitlint/config-conventional": "^20.3.1",
4142
"@semantic-release/exec": "^7.0.3",
43+
"conventional-changelog": "^7.2.1",
4244
"conventional-changelog-conventionalcommits": "^9.3.0",
4345
"husky": "^9.1.7",
4446
"semantic-release": "^25.0.2",

0 commit comments

Comments
 (0)