CI/CD NPM Publish #37
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI/CD NPM Publish | |
on: | |
workflow_dispatch: | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Use Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: "18" | |
- name: Install pnpm | |
run: | | |
if [[ "${{ matrix.node-version }}" == "16" ]]; then | |
npm install -g pnpm@7 | |
else | |
npm install -g pnpm@9 | |
fi | |
- name: Install dependencies | |
run: | | |
if [ -f pnpm-lock.yaml ]; then | |
echo "pnpm-lock.yaml encontrado, ejecutando instalación con frozen lockfile" | |
pnpm install --prefer-frozen-lockfile || pnpm install | |
else | |
echo "pnpm-lock.yaml no encontrado, ejecutando instalación normal" | |
pnpm install | |
fi | |
- name: Run tests | |
run: pnpm test | |
build-and-publish: | |
needs: test | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Use Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: "18" | |
registry-url: "https://registry.npmjs.org" | |
- name: Install pnpm | |
run: | | |
if [[ "${{ matrix.node-version }}" == "16" ]]; then | |
npm install -g pnpm@7 | |
else | |
npm install -g pnpm@9 | |
fi | |
- name: Install dependencies | |
run: | | |
if [ -f pnpm-lock.yaml ]; then | |
echo "pnpm-lock.yaml encontrado, ejecutando instalación con frozen lockfile" | |
pnpm install --prefer-frozen-lockfile || pnpm install | |
else | |
echo "pnpm-lock.yaml no encontrado, ejecutando instalación normal" | |
pnpm install | |
fi | |
- name: Build | |
run: pnpm run build | |
- name: Automated Version Bump | |
id: bump_version | |
uses: TriPSs/conventional-changelog-action@v5 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
preset: angular | |
tag-prefix: v | |
skip-on-empty: false | |
- name: Publish to npm | |
run: pnpm publish --access public | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
if: steps.bump_version.outputs.version != '' |