Bump version from 3.8.7 to 3.8.8 #3
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: | |
| - main | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Get package version | |
| id: package-version | |
| run: | | |
| VERSION=$(node -p "require('./package.json').version") | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Current version: $VERSION" | |
| - name: Check if version is formal | |
| id: is-formal-version | |
| run: | | |
| if [[ "${{ steps.package-version.outputs.version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| echo "is_formal=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "is_formal=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Check if version exists on npm | |
| id: check-npm-version | |
| if: steps.is-formal-version.outputs.is_formal == 'true' | |
| run: | | |
| VERSION_EXISTS=$(npm view @cocos/creator-types@${{ steps.package-version.outputs.version }} version || echo "not_found") | |
| if [[ "$VERSION_EXISTS" == "not_found" ]]; then | |
| echo "version_exists=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "version_exists=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Publish to npm | |
| if: steps.is-formal-version.outputs.is_formal == 'true' && steps.check-npm-version.outputs.version_exists == 'false' | |
| run: npm publish | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |