Skip to content

Fix test import and exclude build directory from Vitest #2

Fix test import and exclude build directory from Vitest

Fix test import and exclude build directory from Vitest #2

name: Publish Preview Packages
on:
push:
branches-ignore:
- "dependabot/**"
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/ci-setup
- name: Configure npm for GitHub Packages
run: |
echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" >> ~/.npmrc
- name: Build package
run: pnpm build
- name: Generate version string
id: version
run: |
BRANCH="${GITHUB_REF_NAME}"
# Sanitize branch name for npm (replace invalid chars with -)
BRANCH_SAFE=$(echo "$BRANCH" | sed 's/[^a-zA-Z0-9-]/-/g' | sed 's/--*/-/g' | sed 's/^-//' | sed 's/-$//')
SHORT_SHA="${GITHUB_SHA::7}"
VERSION="0.0.0-${BRANCH_SAFE}.${SHORT_SHA}"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Publishing version: $VERSION"
- name: Update package version
run: pnpm version ${{ steps.version.outputs.version }} --no-git-tag-version
- name: Publish package
run: pnpm publish --access public --tag preview --no-git-checks
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Summary
run: |
echo "## Published Package" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Version: \`${{ steps.version.outputs.version }}\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Install with:" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY
echo "pnpm add @casekit/unindent@${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
cleanup:
runs-on: ubuntu-latest
needs: publish
permissions:
packages: write
steps:
- name: Delete old preview versions
uses: actions/delete-package-versions@v5
with:
package-name: unindent
package-type: npm
min-versions-to-keep: 50
delete-only-pre-release-versions: true
token: ${{ secrets.GITHUB_TOKEN }}