From 084d374dcf1227aff4d731bacf9c60a86b15c0dd Mon Sep 17 00:00:00 2001 From: Chen Yu Date: Fri, 21 Jul 2023 10:15:25 +0800 Subject: [PATCH] ci: add an action to publish pacakges to npm registry on release (#384) ci: add action to publish pacakges to npm registry on release --- .github/workflows/publish-packages.yml | 38 ++++++++++++++++++++++++++ package.json | 3 +- 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/publish-packages.yml diff --git a/.github/workflows/publish-packages.yml b/.github/workflows/publish-packages.yml new file mode 100644 index 00000000..5d2fe037 --- /dev/null +++ b/.github/workflows/publish-packages.yml @@ -0,0 +1,38 @@ +name: Publish packages to npm registry +on: + release: + types: + - published + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set registry + uses: actions/setup-node@v3 + with: + node-version: 18 + registry-url: https://registry.npmjs.org + + - name: restore lerna + uses: actions/cache@v3 + with: + path: '**/node_modules' + key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }} + + - name: Install dependencies + run: npm ci + + - name: Build packages + run: npm run build + + - name: Run test + run: npx lerna run test + + - name: Publish + run: npm run publish:all + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/package.json b/package.json index 7f48fab6..be3cca78 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,8 @@ "lint": "eslint 'packages/*/{src,__tests__}/**/*.ts'", "prepare": "husky install", "format:check": "prettier -cu packages/**/src/*", - "format:write": "prettier -wu packages/**/src/*" + "format:write": "prettier -wu packages/**/src/*", + "publish:all": "npx lerna publish --no-private from-package --yes" }, "devDependencies": { "@typescript-eslint/eslint-plugin": "6.1.0",