Skip to content

Publish React SDK to npm #153

Publish React SDK to npm

Publish React SDK to npm #153

Workflow file for this run

name: Publish React SDK to npm
on:
workflow_dispatch:
inputs:
version:
description: 'Version number for the SDK'
required: true
tag:
description: 'Tag for the SDK version'
required: true
default: 'latest'
permissions:
id-token: write # Required for OIDC, https://docs.npmjs.com/trusted-publishers
contents: read
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
token: ${{ secrets.AMPERSAND_OPS_PAT }}
ref: main
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '24'
cache: 'npm'
registry-url: 'https://registry.npmjs.org/'
- name: Install yarn
run: npm i -g yarn
- name: Install modules
run: yarn
- name: Update version number
run: yarn version --new-version ${{ github.event.inputs.version }} --no-git-tag-version
- name: Build project
run: yarn build
- name: Publish to npm
id: publish_to_npm
run: npm publish --tag ${{ github.event.inputs.tag }}
- name: Push changes back to repository
if: steps.publish_to_npm.conclusion == 'success'
run: |
git config --global user.email "devops@withampersand.com"
git config --global user.name "Ampersand Ops"
git add package.json src/services/version.ts
git commit -m "[ampersand-ops] release: version ${{ github.event.inputs.version }}"
git tag v${{ github.event.inputs.version }}
git remote set-url origin https://x-access-token:${{ secrets.AMPERSAND_OPS_PAT }}@github.com/${{ github.repository }}
git push origin --tags
git push origin HEAD:${{ github.ref }}
env:
GITHUB_TOKEN: ${{ secrets.AMPERSAND_OPS_PAT }}