Skip to content

Commit d064718

Browse files
authored
Merge pull request #37 from numbersprotocol/feature-ci-build
Feature: Test package creation
2 parents bbbb43f + a46f59e commit d064718

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

.github/workflows/build.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# 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
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3+
4+
name: Build npm package
5+
6+
on:
7+
push:
8+
branches:
9+
- 'feature-*'
10+
- 'fix-*'
11+
pull_request:
12+
branches:
13+
- 'main'
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
19+
strategy:
20+
matrix:
21+
node-version: [16.x, 18.x, 20.x]
22+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
23+
24+
steps:
25+
- uses: actions/checkout@v3
26+
- name: Use Node.js ${{ matrix.node-version }}
27+
uses: actions/setup-node@v3
28+
with:
29+
node-version: ${{ matrix.node-version }}
30+
cache: 'yarn'
31+
- run: yarn install
32+
- run: yarn build

.github/workflows/publish-npm.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# This workflow will build and publish a package to npmjs when a version release is created
2+
# https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages#publishing-packages-using-yarn
3+
4+
name: Publish Package to npmjs
5+
6+
on:
7+
push:
8+
tags:
9+
- 'v[0-9]+.[0-9]+.[0-9]+*'
10+
11+
env:
12+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
19+
packages: write
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v3
23+
24+
- name: Setup .npmrc file to publish to npm
25+
uses: actions/setup-node@v3
26+
with:
27+
node-version: 16
28+
registry-url: 'https://registry.npmjs.org'
29+
# Defaults to the user or organization that owns the workflow file
30+
scope: '@numbersprotocol'
31+
32+
- name: Install dependencies
33+
run: yarn install
34+
35+
- name: Build project
36+
run: yarn build
37+
38+
- name: Publish to npm
39+
run: yarn publish --no-git-tag-version
40+
env:
41+
NODE_AUTH_TOKEN: ${{ env.NODE_AUTH_TOKEN }}

0 commit comments

Comments
 (0)