From e5d20b66f6f2a6ee5c5e524d128ae146144426ea Mon Sep 17 00:00:00 2001
From: Marcus Schiesser <mail@marcusschiesser.de>
Date: Fri, 19 Apr 2024 10:02:42 +0800
Subject: [PATCH] ci: add npm publish to release script

---
 .../workflows/{publish.yml => publish_github.yml} |  0
 .github/workflows/release.yml                     | 15 ++++++++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)
 rename .github/workflows/{publish.yml => publish_github.yml} (100%)

diff --git a/.github/workflows/publish.yml b/.github/workflows/publish_github.yml
similarity index 100%
rename from .github/workflows/publish.yml
rename to .github/workflows/publish_github.yml
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index e5ba0da9..cf22a16d 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -25,7 +25,20 @@ jobs:
       - name: Install dependencies
         run: pnpm install
 
-      - name: Create Release Pull Request
+      - name: Add auth token to .npmrc file
+        run: |
+          cat << EOF >> ".npmrc"
+            //registry.npmjs.org/:_authToken=$NPM_TOKEN
+          EOF
+        env:
+          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
+
+      - name: Create Release Pull Request or Publish to npm
+        id: changesets
         uses: changesets/action@v1
+        with:
+          # build package and call changeset publish
+          publish: pnpm release
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
-- 
GitLab