Skip to content

Exclude .superpowers/ from npm package #4

Exclude .superpowers/ from npm package

Exclude .superpowers/ from npm package #4

name: Publish Release
on:
push:
branches: [main, master]
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 22
registry-url: https://registry.npmjs.org
- name: Get version
id: version
run: echo "version=$(node -p 'require("./package.json").version')" >> $GITHUB_OUTPUT
- name: Check if tag exists
id: check_tag
run: |
if git rev-parse "v${{ steps.version.outputs.version }}" >/dev/null 2>&1; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Check if npm version published
id: check_npm
if: steps.check_tag.outputs.exists == 'false'
run: |
set +e
OUTPUT=$(npm view "@copilotkit/pathfinder@${{ steps.version.outputs.version }}" version 2>&1)
EXIT_CODE=$?
set -e
if [ $EXIT_CODE -eq 0 ]; then
echo "published=true" >> $GITHUB_OUTPUT
elif echo "$OUTPUT" | grep -qi "404\|not found\|is not in this registry"; then
echo "published=false" >> $GITHUB_OUTPUT
else
echo "::error::npm view failed unexpectedly: $OUTPUT"
exit 1
fi
- name: Install latest npm (OIDC requires >= 11.5.1)
if: steps.check_tag.outputs.exists == 'false' && steps.check_npm.outputs.published == 'false'
run: npm install -g npm@latest
- name: Install and build
if: steps.check_tag.outputs.exists == 'false' && steps.check_npm.outputs.published == 'false'
run: npm ci && npm run build
- name: Publish to npm (OIDC trusted publishing)
id: npm_publish
if: steps.check_tag.outputs.exists == 'false' && steps.check_npm.outputs.published == 'false'
run: npm publish --access public
- name: Create tag and release
if: steps.check_tag.outputs.exists == 'false' && (steps.check_npm.outputs.published == 'true' || steps.npm_publish.outcome == 'success')
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git tag "v${{ steps.version.outputs.version }}"
git push origin "v${{ steps.version.outputs.version }}"
gh release create "v${{ steps.version.outputs.version }}" --generate-notes