Skip to content

rm npm publish from CI, use pnpm run release #54

rm npm publish from CI, use pnpm run release

rm npm publish from CI, use pnpm run release #54

Workflow file for this run

name: ci
on:
# Run workflow when a PR is merged onto main
push:
tags:
- 'v*.*.*'
branches:
- main
# Run workflow on any open PR against main branch
pull_request:
types: ['opened', 'reopened', 'ready_for_review', 'synchronize']
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
pr-check:
if: ${{ github.event.pull_request.draft == false }}
runs-on: ubuntu-latest
env:
NODE_ENV: development
steps:
# Checkout repository files
- name: Checkout repository
uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
# Add Node.js and npm to runner
- name: Setup node
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'pnpm'
# Install project dependencies with pnpm
- name: Install dependencies
env:
# Note: NODE_ENV needs to be set to development to
# install jest and other dev dependencies
NODE_ENV: development
run: pnpm install
# Check that packages can build without errors
- name: Builds without errors
env:
NODE_ENV: production
run: pnpm build
# Check for linting errors
- name: Check for linting errors
run: pnpm lint
# Check that project unit tests are successful
- name: Run unit tests
run: pnpm test
publish:
needs: pr-check
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
- name: Set up node
uses: actions/setup-node@v4
with:
node-version: "18.18.0"
registry-url: 'https://registry.npmjs.org'
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
- name: Build
run: pnpm build
- name: Test package publishing (verify workspace:* resolution)
working-directory: packages
run: |
# Test that pnpm resolves workspace:* dependencies correctly when packing
for package in */; do
echo "Testing package: $package"
cd "$package"
# Create a pack tarball - pnpm will resolve workspace:* during packing
pnpm pack --quiet
# Extract and check that workspace:* was resolved to actual versions
tarball=$(ls *.tgz | head -1)
tar -xzOf "$tarball" package/package.json | grep -q '"workspace:\*"' && (echo "✗ ERROR: workspace:* not resolved in $package" && rm -f "$tarball" && exit 1) || echo "✓ workspace:* resolved correctly in $package"
rm -f "$tarball"
cd ..
done
- name: Publish to npm
run: |
if [[ ${GITHUB_REF} == *alpha* ]]; then
pnpm publish -r --access public --tag alpha --no-git-checks
elif [[ ${GITHUB_REF} == *beta* ]]; then
pnpm publish -r --access public --tag beta --no-git-checks
else
pnpm publish -r --access public --tag latest --no-git-checks
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}