Skip to content

Commit 3d96b7a

Browse files
committed
chore: update release action to detect version and tag
chore: remove unnecessary frozen-lockfile which is applied automatically on CI
1 parent 795ff4b commit 3d96b7a

4 files changed

Lines changed: 36 additions & 9 deletions

File tree

.github/actions/setup-node/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ runs:
1414
node-version: 20
1515
cache: 'pnpm'
1616

17-
- run: pnpm install --frozen-lockfile
17+
- run: pnpm install
1818
shell: bash

.github/workflows/release.yml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,31 @@ jobs:
2020
- name: Setup
2121
uses: ./.github/actions/setup-node
2222

23+
- name: Version packages
24+
run: |
25+
if [ -n "$(find .changeset -name '*.md' ! -name 'README.md' 2>/dev/null)" ]; then
26+
./scripts/changeset-version.sh
27+
fi
28+
2329
- name: Create Release Pull Request or Publish to npm
2430
id: changesets
2531
uses: changesets/action@e0145edc7d9d8679003495b11f87bd8ef63c0cba # v1.5.3
2632
with:
27-
version: pnpm run version
28-
commit: 'chore: version packages'
29-
title: 'chore: version packages'
33+
version: "true"
34+
commit: 'chore: ${{ env.VERSION }}'
35+
title: 'chore: ${{ env.VERSION }}'
3036
publish: pnpm publish:npm
3137
env:
3238
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3339
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
3440

3541
- name: Create git tags
36-
if: steps.changesets.outputs.published == 'true'
42+
if: env.VERSION
3743
run: |
38-
VERSION=$(node -p "require('./packages/cli/package.json').version")
39-
git tag "v$VERSION"
40-
git push origin "v$VERSION"
44+
TAG="v${{ env.VERSION }}"
45+
if git ls-remote --tags origin | grep -q "refs/tags/$TAG$"; then
46+
echo "Tag $TAG already exists, skipping"
47+
else
48+
git tag "$TAG"
49+
git push origin "$TAG"
50+
fi

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"dev": "pnpm --filter='./packages/**' -r --parallel --stream run dev",
1515
"validate": "pnpm typecheck && pnpm lint && pnpm test",
1616
"link-packages": "node ./scripts/linkPackages.mjs",
17-
"version": "changeset version && ./scripts/update-template-dependencies.sh && pnpm install --no-frozen-lockfile",
17+
"version": "./scripts/changeset-version.sh",
1818
"publish:npm": "./scripts/npm-publish.sh",
1919
"verdaccio:init": "node ./scripts/verdaccio-init.mjs",
2020
"verdaccio:publish": "node ./scripts/verdaccio-publish.mjs",

scripts/changeset-version.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Run changeset version
5+
pnpm changeset version
6+
7+
# Update template dependencies (templates/ and packages/*/template/)
8+
./scripts/update-template-dependencies.sh
9+
10+
# Regenerate lockfile with updated dependencies
11+
pnpm install --no-frozen-lockfile
12+
13+
# Export version for GitHub Actions commit message
14+
if [ -n "$GITHUB_ENV" ]; then
15+
VERSION=$(node -p "require('./packages/cli/package.json').version")
16+
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
17+
fi

0 commit comments

Comments
 (0)