Skip to content

Workflow file for this run

name: Publish Package and Create Release
on:
push:
tags:
- 'v*'
jobs:
build-and-publish:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: List build output
run: |
echo "Listing contents of the dist directory:"
ls -R dist
- name: Find built files
id: find_files
run: |
CJS_FILE=$(find dist -name "*.cjs.js" -or -name "index.js" -or -name "index.jsx" | grep "/cjs/" | head -n 1)
ESM_FILE=$(find dist -name "*.esm.js" -or -name "index.js" -or -name "index.jsx" | grep "/esm/" | head -n 1)
TYPES_FILE=$(find dist -name "index.d.ts" | head -n 1)
echo "CJS file: $CJS_FILE"
echo "ESM file: $ESM_FILE"
echo "Types file: $TYPES_FILE"
echo "cjs_file=$CJS_FILE" >> $GITHUB_OUTPUT
echo "esm_file=$ESM_FILE" >> $GITHUB_OUTPUT
echo "types_file=$TYPES_FILE" >> $GITHUB_OUTPUT
- name: Publish to npm
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
files: |
${{ steps.find_files.outputs.cjs_file }}
${{ steps.find_files.outputs.esm_file }}
${{ steps.find_files.outputs.types_file }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}