Update build.yml to run only on Ubuntu and with specific Node versions #40
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: Pre-release CI | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-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 }} |