π [FIX/#73] λ²μ 컀맨λ μλ¬ ν΄κ²° #33
Workflow file for this run
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/CD | |
| on: | |
| push: | |
| branches: [master] | |
| pull_request: | |
| branches: [master] | |
| jobs: | |
| test-and-deploy: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| packages: write | |
| id-token: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: latest | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'pnpm' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Run build | |
| run: pnpm build | |
| - name: Setup Git config | |
| if: github.ref == 'refs/heads/master' && github.event_name == 'push' | |
| run: | | |
| git config --local user.email "tell280210@gmail.com" | |
| git config --local user.name "Colbrush Bot" | |
| - name: Analyze commits and auto version | |
| if: github.ref == 'refs/heads/master' && github.event_name == 'push' | |
| run: | | |
| COMMIT_COUNT=$(git rev-list --count HEAD) | |
| if [ "$COMMIT_COUNT" -gt 10 ]; then | |
| COMMITS=$(git log --pretty=format:"%s" HEAD~10..HEAD) | |
| else | |
| COMMITS=$(git log --pretty=format:"%s" HEAD) | |
| fi | |
| echo "Analyzing commits:" | |
| echo "$COMMITS" | |
| VERSION_TYPE="patch" # default | |
| # MAJOR | |
| if echo "$COMMITS" | grep -qiE "(BREAKING|π₯)"; then | |
| VERSION_TYPE="major" | |
| echo "π¨ Breaking change detected - MAJOR version bump" | |
| # MINOR | |
| elif echo "$COMMITS" | grep -qiE "feat"; then | |
| VERSION_TYPE="minor" | |
| echo "β¨ New feature detected - MINOR version bump" | |
| # PATCH | |
| elif echo "$COMMITS" | grep -qiE "fix"; then | |
| VERSION_TYPE="patch" | |
| echo "π Bug fix detected - PATCH version bump" | |
| # κΈ°ν λ³κ²½μ¬ν (PATCH) | |
| else | |
| VERSION_TYPE="patch" | |
| echo "π Other changes detected - PATCH version bump" | |
| fi | |
| # νμ¬ λ²μ νμΈ | |
| CURRENT_VERSION=$(node -p "require('./package.json').version") | |
| echo "Current version: $CURRENT_VERSION" | |
| # μλ λ²μ μ λ°μ΄νΈ | |
| npm version $VERSION_TYPE --no-git-tag-version | |
| # μ λ²μ νμΈ | |
| NEW_VERSION=$(node -p "require('./package.json').version") | |
| echo "New version: $NEW_VERSION" | |
| # λ³κ²½μ¬ν μ»€λ° | |
| git add package.json | |
| git commit -m "π Auto bump $VERSION_TYPE version to v$NEW_VERSION" || exit 0 | |
| # Git νκ·Έ μμ± | |
| git tag "v$NEW_VERSION" | |
| # μ격 μ μ₯μμ νΈμ (νκ·Έ ν¬ν¨) | |
| git push origin master --tags | |
| # npmμ λ°°ν¬ | |
| echo "Publishing version $NEW_VERSION to npm..." | |
| pnpm publish --no-git-checks | |
| echo "β Successfully published v$NEW_VERSION to npm!" | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |