Skip to content

Build and Publish

Build and Publish #383

Workflow file for this run

name: Build and Publish
on:
push:
branches:
- '**'
tags:
- v*
pull_request:
branches:
- '**'
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
strategy:
matrix:
node-version: [18.x, 20.x, 21.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
registry-url: 'https://registry.npmjs.org'
scope: '@opperai'
- name: Install dependencies
run: npm install
- name: Build
run: npm run build
- name: Test
run: npm test
- name: Publish to NPM
if: matrix.node-version == '21.x' && startsWith(github.ref, 'refs/tags/')
run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- name: Create GitHub Release
if: matrix.node-version == '21.x' && startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release create '${{ github.ref_name }}' --repo '${{ github.repository }}' --notes ""
- name: Upload artifact signatures to GitHub Release
if: matrix.node-version == '21.x' && startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release upload '${{ github.ref_name }}' dist/** --repo '${{ github.repository }}'