Skip to content

feat: added react sdk #58

feat: added react sdk

feat: added react sdk #58

Workflow file for this run

name: Build and Publish React Package
on:
push:
branches:
- main
- master
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test
build-and-publish:
needs: test
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18
registry-url: https://registry.npmjs.org/
always-auth: true
- name: Install dependencies
run: npm ci
- name: Install PostCSS CLI globally (for build step)
run: npm install -g postcss postcss-cli
- name: Build package
run: npm run build
- name: Publish to npm
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_CONFIG_PROVENANCE: false
run: npm publish --access public
create_release:
name: Create GitHub Release
needs: build-and-publish
runs-on: ubuntu-latest
permissions:
contents: write
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get version and create tag
id: version
run: |
VERSION=$(jq -r '.version' package.json)
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
echo "TAG_NAME=v${VERSION}" >> $GITHUB_OUTPUT
if git tag -l "v${VERSION}" | grep -q "v${VERSION}"; then
echo "TAG_EXISTS=true" >> $GITHUB_OUTPUT
else
echo "TAG_EXISTS=false" >> $GITHUB_OUTPUT
fi
- name: Create and push tag
if: steps.version.outputs.TAG_EXISTS == 'false'
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "${{ steps.version.outputs.TAG_NAME }}" -m "Release ${{ steps.version.outputs.TAG_NAME }}"
git push origin "${{ steps.version.outputs.TAG_NAME }}"
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "# Release ${{ steps.version.outputs.TAG_NAME }}" > release-notes.md
echo "" >> release-notes.md
echo "## Changes" >> release-notes.md
echo "- Automated release from commit $(git rev-parse --short HEAD)" >> release-notes.md
gh release create "${{ steps.version.outputs.TAG_NAME }}" \
--title "Release ${{ steps.version.outputs.TAG_NAME }}" \
--notes-file release-notes.md