Skip to content

Commit

Permalink
📦 NEW: workflow to publish npm package based on release tag (#709)
Browse files Browse the repository at this point in the history
* 📦 NEW: workflow to publish npm package based on release tag

* 👌 IMPROVE: remove publish flow
  • Loading branch information
antoantonyk authored Nov 4, 2023
1 parent 2864035 commit 1502ca9
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 46 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/ci-publish.yml
Original file line number Diff line number Diff line change
@@ -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 }}
46 changes: 0 additions & 46 deletions .github/workflows/ci-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

0 comments on commit 1502ca9

Please sign in to comment.