minor: added example for a syntax check script #25
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| publish: | |
| name: Build and Publish | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v2 | |
| with: | |
| version: 9 | |
| - name: Get pnpm store directory | |
| shell: bash | |
| run: | | |
| echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
| - name: Setup pnpm cache | |
| uses: actions/cache@v3 | |
| with: | |
| path: ${{ env.STORE_PATH }} | |
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm-store- | |
| - name: Get package version | |
| id: get_version | |
| run: | | |
| CURRENT_VERSION=$(node -p "require('./package.json').version") | |
| echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT | |
| - name: Check version on npm | |
| id: check_version | |
| run: | | |
| NPM_VERSION=$(npm view promptl-ai version 2>/dev/null || echo "0.0.0") | |
| if [ "${{ steps.get_version.outputs.version }}" != "$NPM_VERSION" ]; then | |
| echo "should_publish=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "should_publish=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Install dependencies | |
| if: steps.check_version.outputs.should_publish == 'true' | |
| run: pnpm install | |
| - name: Build package (with workspace dependencies) | |
| if: steps.check_version.outputs.should_publish == 'true' | |
| run: pnpm run build | |
| - name: Run linter | |
| if: steps.check_version.outputs.should_publish == 'true' | |
| run: pnpm run lint | |
| - name: Run typescript checker | |
| if: steps.check_version.outputs.should_publish == 'true' | |
| run: pnpm run tc | |
| - name: Run tests | |
| if: steps.check_version.outputs.should_publish == 'true' | |
| run: pnpm run test | |
| - name: Publish to npm | |
| if: steps.check_version.outputs.should_publish == 'true' | |
| run: pnpm publish --access public --no-git-checks | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |