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

XT-2856: Create GitHub workflow to build npm package #461

Merged
merged 3 commits into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Build and publish NPM package

on:
workflow_dispatch:
inputs:
node_version:
default: '19'
description: 'Node version to use'
required: true
type: string

jobs:
build-package:
environment: release
runs-on: ubuntu-22.04
steps:
- uses: actions/[email protected]
with:
fetch-depth: 0 # npm run prod requires tags, sadly this is the only way to get them.
- uses: actions/setup-node@v3
with:
node-version: ${{ inputs.node_version }}
registry-url: 'https://registry.npmjs.org' # Must explicitly set this for NODE_AUTH_TOKEN to work below
- name: Install dependencies
run: npm install --include=dev
- name: Test with npm
run: npm run test
- name: Build with npm
run: npm run prod
- name: Publish with npm
if: startsWith(github.ref, 'refs/tags')
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
npm config set git-tag-version=false
npm version $(git describe --tags)
npm publish --access public
Loading