Add the github actions. Add the publishing #3
Workflow file for this run
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: packages/juster-sdk | |
on: | |
push: | |
paths: | |
- 'packages/juster-sdk/**' | |
- 'package.json' | |
- 'package-lock.json' | |
- '.github/workflows/juster-sdk.yml' | |
branches: | |
- master | |
- dev | |
tags: | |
- 'juster-sdk@*.*.*' | |
pull_request: | |
env: | |
node-version: 22 | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Clone repository | |
uses: actions/checkout@v4 | |
- name: Set up Node.js ${{ env.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.node-version }} | |
cache: 'npm' | |
- name: Print environment info | |
run: | | |
node --version | |
npm --version | |
- name: Install dependencies | |
run: npm ci | |
- name: Build the package | |
run: npm run build -w @juster-finance/sdk | |
- name: Upload the build as an artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: juster-sdk | |
path: | | |
packages/juster-sdk/dist | |
packages/juster-sdk/package.json | |
packages/juster-sdk/LICENSE | |
if-no-files-found: error | |
retention-days: 1 | |
lint: | |
name: Lint | |
runs-on: ubuntu-latest | |
steps: | |
- name: Clone repository | |
uses: actions/checkout@v4 | |
- name: Set up Node.js ${{ env.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.node-version }} | |
cache: 'npm' | |
- name: Print environment info | |
run: | | |
node --version | |
npm --version | |
- name: Install dependencies | |
run: npm ci | |
- name: Lint | |
run: npm run lint -w @juster-finance/sdk | |
publish-npm: | |
name: Publish to NPM | |
runs-on: ubuntu-latest | |
needs: [build, lint] | |
if: ${{ contains(github.ref, 'refs/tags/juster-sdk@') }} | |
steps: | |
- name: Download the build from the artifacts storage | |
uses: actions/download-artifact@v4 | |
with: | |
name: juster-sdk | |
- name: Set up Node.js ${{ env.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
registry-url: 'https://registry.npmjs.org' | |
node-version: ${{ env.node-version }} | |
- name: Print environment info | |
run: | | |
node --version | |
npm --version | |
- name: Publish | |
run: npm publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |