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

Feature: Test package creation #37

Merged
merged 8 commits into from
Jan 10, 2024
Merged
32 changes: 32 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Build npm package

on:
push:
branches:
- 'feature-*'
- 'fix-*'
pull_request:
branches:
- 'main'

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- run: yarn install
- run: yarn build
41 changes: 41 additions & 0 deletions .github/workflows/publish-npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# This workflow will build and publish a package to npmjs when a version release is created
# https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages#publishing-packages-using-yarn

name: Publish Package to npmjs

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*'

env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup .npmrc file to publish to npm
uses: actions/setup-node@v3
with:
node-version: 16
registry-url: 'https://registry.npmjs.org'
# Defaults to the user or organization that owns the workflow file
scope: '@numbersprotocol'

- name: Install dependencies
run: yarn install

- name: Build project
run: yarn build

- name: Publish to npm
run: yarn publish --no-git-tag-version
env:
NODE_AUTH_TOKEN: ${{ env.NODE_AUTH_TOKEN }}