feat: add Nuxt installation check and update setup completion messages #13
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 | |
| - master | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| cache: "npm" | |
| - name: Install dependencies | |
| run: npm i --legacy-peer-deps | |
| - name: Prepare Nuxt environment | |
| run: npm run dev:prepare | |
| # - name: Run linting | |
| # run: npm run lint | |
| publish: | |
| needs: test | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| cache: "npm" | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Install dependencies | |
| run: npm i --legacy-peer-deps | |
| - name: Prepare Nuxt environment | |
| run: npm run dev:prepare | |
| - name: Build module | |
| run: npm run prepack | |
| - name: Configure Git | |
| run: | | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Check if version changed | |
| id: version-check | |
| run: | | |
| CURRENT_VERSION=$(node -p "require('./package.json').version") | |
| echo "current-version=$CURRENT_VERSION" >> $GITHUB_OUTPUT | |
| # Check if this version exists on npm | |
| if npm view @atmoner/nuxt-electron@$CURRENT_VERSION version >/dev/null 2>&1; then | |
| echo "version-exists=true" >> $GITHUB_OUTPUT | |
| echo "Version $CURRENT_VERSION already exists on npm" | |
| else | |
| echo "version-exists=false" >> $GITHUB_OUTPUT | |
| echo "Version $CURRENT_VERSION is new" | |
| fi | |
| - name: Bump version | |
| if: steps.version-check.outputs.version-exists == 'true' | |
| run: | | |
| npm version patch --no-git-tag-version | |
| NEW_VERSION=$(node -p "require('./package.json').version") | |
| echo "New version: $NEW_VERSION" | |
| - name: Commit version bump | |
| if: steps.version-check.outputs.version-exists == 'true' | |
| run: | | |
| git add package.json | |
| git commit -m "chore: bump version to $(node -p "require('./package.json').version") [skip ci]" | |
| git push | |
| - name: Create Git tag | |
| run: | | |
| VERSION=$(node -p "require('./package.json').version") | |
| git tag -a "v$VERSION" -m "Release v$VERSION" | |
| git push origin "v$VERSION" | |
| - name: Publish to NPM | |
| run: npm publish --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Create GitHub Release | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: v${{ steps.version-check.outputs.current-version }} | |
| release_name: Release v${{ steps.version-check.outputs.current-version }} | |
| body: | | |
| Automated release of @atmoner/nuxt-electron v${{ steps.version-check.outputs.current-version }} | |
| ## Changes | |
| See the [changelog](https://github.com/${{ github.repository }}/compare/v${{ steps.version-check.outputs.current-version }}...HEAD) for details. | |
| draft: false | |
| prerelease: false |