feat(docs): add comprehensive commit message and versioning guidelines #2
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: CI | |
| on: | |
| push: | |
| branches: [main, develop] | |
| pull_request: | |
| branches: [main, develop] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| node-version: [18, 20, 22] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10 | |
| - name: Get pnpm store directory | |
| shell: bash | |
| run: | | |
| echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
| - name: Setup pnpm cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ env.STORE_PATH }} | |
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm-store- | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Run typecheck | |
| run: pnpm typecheck | |
| - name: Run linting | |
| run: pnpm lint | |
| - name: Check formatting | |
| run: pnpm format:check | |
| - name: Run tests | |
| run: pnpm test:run | |
| - name: Run tests with coverage | |
| run: pnpm test:coverage | |
| - name: Build package | |
| run: pnpm build | |
| - name: Upload coverage reports | |
| uses: codecov/codecov-action@v4 | |
| if: matrix.node-version == 22 | |
| with: | |
| file: ./coverage/lcov.info | |
| flags: unittests | |
| name: codecov-umbrella | |
| fail_ci_if_error: false | |
| publish: | |
| needs: test | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
| environment: npm-publish | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10 | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Build package | |
| run: pnpm build | |
| - name: Check for version bump needed | |
| id: version-check | |
| run: | | |
| # Check if there are any commits since last tag | |
| if git describe --tags --exact-match HEAD >/dev/null 2>&1; then | |
| echo "no-bump=true" >> $GITHUB_OUTPUT | |
| echo "No version bump needed - already tagged" | |
| else | |
| echo "no-bump=false" >> $GITHUB_OUTPUT | |
| echo "Version bump needed" | |
| fi | |
| - name: Auto-increment version | |
| if: steps.version-check.outputs.no-bump == 'false' | |
| run: | | |
| # Get the last commit message | |
| COMMIT_MSG=$(git log -1 --pretty=%B) | |
| # Determine version bump type based on conventional commits | |
| if echo "$COMMIT_MSG" | grep -q "^feat("; then | |
| echo "Bumping minor version (new feature)" | |
| pnpm version minor --no-git-tag-version | |
| elif echo "$COMMIT_MSG" | grep -q "^fix("; then | |
| echo "Bumping patch version (bug fix)" | |
| pnpm version patch --no-git-tag-version | |
| elif echo "$COMMIT_MSG" | grep -q "^BREAKING CHANGE\|^feat!(\|^fix!("; then | |
| echo "Bumping major version (breaking change)" | |
| pnpm version major --no-git-tag-version | |
| else | |
| echo "Bumping patch version (default)" | |
| pnpm version patch --no-git-tag-version | |
| fi | |
| # Create and push tag | |
| NEW_VERSION=$(node -p "require('./package.json').version") | |
| git config --local user.email "[email protected]" | |
| git config --local user.name "GitHub Action" | |
| git add package.json | |
| git commit -m "chore(release): bump version to $NEW_VERSION" | |
| git tag "v$NEW_VERSION" | |
| git push origin main | |
| git push origin "v$NEW_VERSION" | |
| - name: Publish to npm | |
| if: steps.version-check.outputs.no-bump == 'false' | |
| run: pnpm publish --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |