Skip to content

Create and publish React npm package #112

Create and publish React npm package

Create and publish React npm package #112

Workflow file for this run

name: Create and publish React npm package
on:
workflow_dispatch:
inputs:
reactVersion:
required: true
type: choice
options:
- '17'
- '18'
description: The version of react you want to build
permissions:
contents: read
jobs:
publish_react:
runs-on: ubuntu-latest
if: github.repository == 'trimble-oss/modus-web-components'
defaults:
run:
working-directory: ./react-workspace/react-${{ github.event.inputs.reactVersion }}
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
# Setup Node, build, and publish to the npm, and GitHub registries
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
- name: Install Modus Web Components
run: npm ci
working-directory: ./stencil-workspace
- name: Build Modus Web Components
run: npm run build
working-directory: ./stencil-workspace
- name: Install React ${{ github.event.inputs.reactVersion }}
run: npm ci
- name: Build React ${{ github.event.inputs.reactVersion }}
run: npm run build
- name: Set npm Registry Auth Token
run: npm set //registry.npmjs.org/:_authToken ${{ secrets.NPM_TRIMBLE_OSS_AUTOMATION_TOKEN }}
- name: Publish React npm Package Publicly
run: npm publish --access public
- name: Set GitHub Registry Auth Token
run: npm set //npm.pkg.github.com/:_authToken ${{ secrets.GITHUB_TOKEN }}
- name: Publish React npm Package to GitHub Registry
run: npm publish --access public --ignore-scripts --@trimble-oss:registry='https://npm.pkg.github.com'