Clean up repository (#5) #7
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 to NPM | |
| on: | |
| push: | |
| branches: | |
| - master | |
| - main | |
| workflow_dispatch: # Allow manual triggering | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "18" | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v2 | |
| with: | |
| version: latest | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Run tests | |
| run: pnpm --filter syncrostate test | |
| - name: Build package | |
| run: pnpm --filter syncrostate run package | |
| - name: Check if version changed | |
| id: version-check | |
| run: | | |
| CURRENT_VERSION=$(node -p "require('./package/package.json').version") | |
| PUBLISHED_VERSION=$(npm view syncrostate version 2>/dev/null || echo "0.0.0") | |
| echo "current=$CURRENT_VERSION" >> $GITHUB_OUTPUT | |
| echo "published=$PUBLISHED_VERSION" >> $GITHUB_OUTPUT | |
| if [ "$CURRENT_VERSION" != "$PUBLISHED_VERSION" ]; then | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| echo "Version changed from $PUBLISHED_VERSION to $CURRENT_VERSION" | |
| else | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| echo "Version unchanged: $CURRENT_VERSION" | |
| fi | |
| - name: Publish to NPM | |
| if: steps.version-check.outputs.changed == 'true' | |
| run: | | |
| cd package | |
| npm publish | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |