Skip to content

[utils] Publish v0.1.2 #7

[utils] Publish v0.1.2

[utils] Publish v0.1.2 #7

Workflow file for this run

name: Publish Package
on:
push:
tags:
- '*@v*.*.*' # Trigger on tags like [email protected], [email protected], [email protected]
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read # Allow reading the repository content
id-token: write # Required for provenance and JSR authentication
container:
image: node:20
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Parse Tag
id: parse_tag
run: |
# Extract the tag name (e.g., [email protected])
TAG_NAME="${GITHUB_REF##*/}"
PACKAGE_SHORT_NAME="${TAG_NAME%@*}"
VERSION="${TAG_NAME#*@}"
if [ "${PACKAGE_SHORT_NAME}" = "chuchi" ]; then
PACKAGE_FOLDER="chuchi" # Special case for chuchi
else
PACKAGE_FOLDER="chuchi-${PACKAGE_SHORT_NAME}" # Add prefix for other packages
fi
echo "PACKAGE_SHORT_NAME=${PACKAGE_SHORT_NAME}" >> $GITHUB_ENV
echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "PACKAGE_FOLDER=${PACKAGE_FOLDER}" >> $GITHUB_ENV
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Install Dependencies
run: npm ci
- name: Run lint
run: |
cd ${PACKAGE_FOLDER}
npm run lint
- name: Build Package
run: |
cd ${PACKAGE_FOLDER} # Navigate to the correct package folder
echo "Building package from ${PACKAGE_FOLDER}"
npm run build
- name: Publish to npm
run: |
cd ${PACKAGE_FOLDER} # Navigate to the correct package folder
echo "Publishing package from ${PACKAGE_FOLDER} with version ${VERSION}"
npm publish --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish to JSR
run: |
echo "Publishing to JSR for package ${PACKAGE_SHORT_NAME}"
npx jsr publish