Skip to content

Commit b58de5f

Browse files
committed
ci: improve release workflows with tag detection and npm ci
- Added `fetch-tags: true` for `checkout` actions to improve tag availability. - Updated dependency installation to use `npm ci` with `HUSKY=0` environment variable. - Implemented logic to detect the latest tag and include it in release commands. - Enhanced `release` and `release:preview` steps with conditional latest tag usage.
1 parent 7f635eb commit b58de5f

2 files changed

Lines changed: 26 additions & 4 deletions

File tree

.github/workflows/release-prepare.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
uses: actions/checkout@v4
2525
with:
2626
fetch-depth: 0
27+
fetch-tags: true
2728

2829
- name: Setup Node.js
2930
uses: actions/setup-node@v4
@@ -36,9 +37,19 @@ jobs:
3637
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
3738
3839
- name: Install dependencies
39-
run: npm install
40+
env:
41+
HUSKY: 0
42+
run: npm ci
43+
44+
- name: Detect latest tag
45+
run: echo "LATEST_TAG=$(git tag --list 'v*' --sort=-v:refname | head -n 1)" >> $GITHUB_ENV
4046

4147
- name: Release (preview)
4248
env:
4349
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44-
run: npm run release:preview
50+
run: |
51+
if [ -n "${LATEST_TAG}" ]; then
52+
npm run release:preview -- --plugins.@release-it/conventional-changelog.gitRawCommitsOpts.from="${LATEST_TAG}"
53+
else
54+
npm run release:preview
55+
fi

.github/workflows/release-publish.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
uses: actions/checkout@v4
2525
with:
2626
fetch-depth: 0
27+
fetch-tags: true
2728

2829
- name: Setup Node.js
2930
uses: actions/setup-node@v4
@@ -37,10 +38,20 @@ jobs:
3738
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
3839
3940
- name: Install dependencies
40-
run: npm install
41+
env:
42+
HUSKY: 0
43+
run: npm ci
44+
45+
- name: Detect latest tag
46+
run: echo "LATEST_TAG=$(git tag --list 'v*' --sort=-v:refname | head -n 1)" >> $GITHUB_ENV
4147

4248
- name: Release (publish)
4349
env:
4450
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4551
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
46-
run: npm run release -- --ci
52+
run: |
53+
if [ -n "${LATEST_TAG}" ]; then
54+
npm run release -- --ci --plugins.@release-it/conventional-changelog.gitRawCommitsOpts.from="${LATEST_TAG}"
55+
else
56+
npm run release -- --ci
57+
fi

0 commit comments

Comments
 (0)