Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 30 additions & 25 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
jobs:
test-and-deploy:
runs-on: ubuntu-latest

permissions:
contents: write
packages: write
Expand All @@ -20,47 +20,47 @@ jobs:
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'
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 "[email protected]"
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"
Expand All @@ -78,34 +78,39 @@ jobs:
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"

if git rev-parse "v${NEW_VERSION}" >/dev/null 2>&1; then
echo "Tag v${NEW_VERSION} already exists. Skipping tag creation."
else
git tag "v${NEW_VERSION}"
echo "βœ… Created tag v${NEW_VERSION}"
fi

# 원격 μ €μž₯μ†Œμ— ν‘Έμ‹œ (νƒœκ·Έ 포함)
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 }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}