Skip to content

Commit d8ca569

Browse files
committed
fix(ci): add automatic yarn.lock generation to auto-publish workflow
Fix yarn.lock dependency issue in GitHub Actions workflow - Add automatic yarn.lock generation before Node.js cache setup - Ensure dependencies are installed and lockfile exists before validation - Update commit step to include yarn.lock in version releases - Improve workflow robustness for projects without initial lockfile - Maintain frozen-lockfile strategy for dependency consistency This resolves the "Dependencies lock file is not found" error that occurs when yarn.lock is missing from the repository.
1 parent 1e78c05 commit d8ca569

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

.github/workflows/auto-publish.yml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,23 @@ jobs:
2525
fetch-depth: 0
2626
token: ${{ secrets.GITHUB_TOKEN }}
2727

28-
- name: Setup Node.js
28+
- name: Setup Yarn and generate lockfile
29+
run: |
30+
corepack enable
31+
yarn --version
32+
33+
# Always run yarn install to ensure lockfile exists and is up to date
34+
echo "📦 Running yarn install..."
35+
yarn install
36+
echo "✅ Dependencies installed and lockfile ready"
37+
38+
- name: Setup Node.js with cache
2939
uses: actions/setup-node@v4
3040
with:
3141
node-version: '20'
3242
registry-url: 'https://registry.npmjs.org'
3343
cache: 'yarn'
34-
35-
- name: Setup Yarn
36-
run: |
37-
corepack enable
38-
yarn --version
44+
cache-dependency-path: yarn.lock
3945

4046
- name: Validate branch patterns
4147
id: validate-branch
@@ -212,7 +218,7 @@ jobs:
212218
npm version $NEW_VERSION --no-git-tag-version
213219
214220
# Commit and tag
215-
git add package.json package-lock.json 2>/dev/null || git add package.json
221+
git add package.json yarn.lock 2>/dev/null || git add package.json
216222
git commit -m "chore(release): $NEW_VERSION
217223
218224
Released from: $BRANCH_NAME

0 commit comments

Comments
 (0)