Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

📦 NEW: workflow to publish npm package based on release tag #709

Merged
merged 2 commits into from
Nov 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 }}
Loading