Skip to content

Update Node.js version in publish workflow #27

Update Node.js version in publish workflow

Update Node.js version in publish workflow #27

Workflow file for this run

name: Node.js CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
node-version: [18, 19, 20]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: npm install, build, and test
run: |
npm ci
npm test --if-present
npm run lint
npm run build
env:
CI: true
package:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v2
- name: Use Node.js 18.x
uses: actions/setup-node@v2
with:
node-version: 18.x
- run: npm ci
- run: npm run build
- run: npm version prerelease --preid=ci-$GITHUB_RUN_ID --no-git-tag-version
- run: npm pack
- name: Upload package
uses: actions/upload-artifact@v2
with:
name: package
path: "*.tgz"
publish:
name: "Publish to GitHub Packages"
needs: package
runs-on: ubuntu-latest
if: github.repository_owner == 'Younis-ahmed' && github.ref == 'refs/heads/main'
steps:
- name: Upload
uses: actions/download-artifact@v2
with:
name: package
- uses: actions/setup-node@v2
with:
node-version: 18.x
registry-url: https://npm.pkg.github.com/
scope: '@younis-ahmed'
- run: echo "registry=https://npm.pkg.github.com/Younis-ahmed" >> .npmrc
- run: npm publish $(ls *.tgz)
env:
NODE_AUTH_TOKEN: ${{ secrets.GH_PAT }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GH_PAT }}