From 1502ca9687b8693405134667bcc19b637efaf1b7 Mon Sep 17 00:00:00 2001 From: Anto Antony Date: Sat, 4 Nov 2023 20:22:26 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=A6=20NEW:=20workflow=20to=20publish?= =?UTF-8?q?=20npm=20package=20based=20on=20release=20tag=20(#709)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 📦 NEW: workflow to publish npm package based on release tag * 👌 IMPROVE: remove publish flow --- .github/workflows/ci-publish.yml | 45 ++++++++++++++++++++++++++++++ .github/workflows/ci-workflow.yml | 46 ------------------------------- 2 files changed, 45 insertions(+), 46 deletions(-) create mode 100644 .github/workflows/ci-publish.yml diff --git a/.github/workflows/ci-publish.yml b/.github/workflows/ci-publish.yml new file mode 100644 index 00000000..5417fdb5 --- /dev/null +++ b/.github/workflows/ci-publish.yml @@ -0,0 +1,45 @@ +name: Publish NPM Package +on: + release: + types: + - released + +jobs: + publish: + # check for version in the release tag - example: v1.0.0 + if: contains(github.event.release.tag_name, '^v[0-9]+\.[0-9]+\.[0-9]') + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [16.14.2] + + steps: + - name: Checkout 🛎️ + uses: actions/checkout@v3 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + registry-url: 'https://registry.npmjs.org' + + - name: Install dependencies + run: npm ci + + # TODO - find better approch to install the peer dependencies for local developement + - name: Link lib + run: npm link ./projects/password-strength-meter + + - name: Build - Lib + run: npm run build:lib:prod + + - name: Get package version + id: package-version + uses: martinbeentjes/npm-get-version-action@master + + - name: Publish to npm + run: npm publish dist/password-strength-meter/ + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/ci-workflow.yml b/.github/workflows/ci-workflow.yml index d2f385e7..8b9f29b6 100644 --- a/.github/workflows/ci-workflow.yml +++ b/.github/workflows/ci-workflow.yml @@ -89,49 +89,3 @@ jobs: with: branch: gh-pages # The branch the action should deploy to. folder: docs # The folder the action should deploy. - - publish: - needs: deploy - if: github.event_name == 'push' && github.ref == 'refs/heads/master' - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [16.14.2] - - steps: - - name: Checkout 🛎️ - uses: actions/checkout@v3 - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - cache: 'npm' - registry-url: 'https://registry.npmjs.org' - - - name: Install dependencies - run: npm ci - - # TODO - find better approch to install the peer dependencies for local developement - - name: Link lib - run: npm link ./projects/password-strength-meter - - - name: Build - Lib - run: npm run build:lib:prod - - - name: Get package version - id: package-version - uses: martinbeentjes/npm-get-version-action@master - - - name: Create release - uses: ncipollo/release-action@v1 - with: - tag: v${{ steps.package-version.outputs.current-version}} - commit: ${{ github.sha }} - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Publish to npm - run: npm publish dist/password-strength-meter/ - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}