Skip to content
Merged
Show file tree
Hide file tree
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
86 changes: 3 additions & 83 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI/CD
name: CI

on:
push:
Expand All @@ -7,19 +7,15 @@ on:
branches: [master]

jobs:
test-and-deploy:
build:
runs-on: ubuntu-latest

permissions:
contents: write
packages: write
id-token: write
contents: read

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup pnpm
uses: pnpm/action-setup@v4
Expand All @@ -38,79 +34,3 @@ jobs:

- 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 νƒœκ·Έ 생성
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 }}
59 changes: 59 additions & 0 deletions .github/workflows/publish-npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Publish npm

on:
workflow_dispatch:

permissions:
contents: write
id-token: write

jobs:
publish:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10.23.0

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
cache: "pnpm"
registry-url: "https://registry.npmjs.org"

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Bump version
run: |
git config --local user.email "tell280210@gmail.com"
git config --local user.name "Colbrush Bot"

LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || true)
if [ -n "$LAST_TAG" ]; then
COMMITS=$(git log --pretty=format:"%s" "$LAST_TAG"..HEAD)
else
COMMITS=$(git log --pretty=format:"%s")
fi
VERSION_TYPE="patch"

if echo "$COMMITS" | grep -qiE "(BREAKING|πŸ’₯)"; then
VERSION_TYPE="major"
elif echo "$COMMITS" | grep -qiE "feat"; then
VERSION_TYPE="minor"
fi

npm version "$VERSION_TYPE" -m "chore: bump version to v%s"
git push origin HEAD:master --follow-tags

- name: Publish to npm
run: npm publish --provenance
Loading