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 }}