Skip to content

Commit 80a5257

Browse files
committed
👷 Improve release workflow
1 parent 0985be4 commit 80a5257

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

.github/workflows/release.yml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ jobs:
1212
runs-on: ubuntu-latest
1313

1414
steps:
15-
- uses: actions/checkout@v4
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
1617

1718
- name: Set up Node.js
1819
uses: actions/setup-node@v4
@@ -28,9 +29,10 @@ jobs:
2829
- name: Install dependencies
2930
run: pnpm install
3031

31-
- name: Build
32+
- name: Build package
3233
run: pnpm build
3334

35+
# 🧩 Check if this version is already on npm
3436
- name: Check if version already exists on npm
3537
id: check
3638
run: |
@@ -40,7 +42,7 @@ jobs:
4042
echo "PACKAGE_VERSION=$PACKAGE_VERSION"
4143
echo "version=$PACKAGE_VERSION" >> $GITHUB_OUTPUT
4244
43-
NPM_VERSIONS=$(npm view $PACKAGE_NAME versions --json)
45+
NPM_VERSIONS=$(npm view $PACKAGE_NAME versions --json || echo "[]")
4446
echo "Published versions: $NPM_VERSIONS"
4547
4648
if echo "$NPM_VERSIONS" | grep -q "\"$PACKAGE_VERSION\""; then
@@ -56,19 +58,23 @@ jobs:
5658
run: npm publish --access public
5759
env:
5860
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
59-
NODE_ENV: "production"
61+
NODE_ENV: production
6062

6163
- name: Extract latest changelog entry
62-
if: steps.check.outputs.publish_needed == 'true'
6364
run: |
64-
awk '/^## /{if (p) exit; p=1} p' CHANGELOG.md > LATEST_CHANGELOG.md
65+
if [ -f CHANGELOG.md ]; then
66+
awk '/^## /{if (p) exit; p=1} p' CHANGELOG.md > LATEST_CHANGELOG.md
67+
else
68+
echo "No CHANGELOG.md found." > LATEST_CHANGELOG.md
69+
fi
6570
6671
- name: Create GitHub Release
67-
if: steps.check.outputs.publish_needed == 'true'
72+
if: always()
6873
uses: softprops/action-gh-release@v2
6974
with:
7075
tag_name: "v${{ steps.check.outputs.version }}"
7176
name: "Release v${{ steps.check.outputs.version }}"
7277
body_path: LATEST_CHANGELOG.md
78+
make_latest: true
7379
env:
74-
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
80+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)