diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 8fbe0da..d81a8ce 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -35,6 +35,17 @@ jobs: echo "VERSION=$VERSION" >> $GITHUB_OUTPUT echo "Extracted version: $VERSION" + - name: Create and push tag + run: | + git config --global user.name "GitHub Actions Bot" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + + TAG_NAME="v${{ steps.extract-version.outputs.VERSION }}" + echo "Creating tag: $TAG_NAME" + + git tag -a $TAG_NAME -m "Release $TAG_NAME" + git push origin $TAG_NAME + - name: Read CHANGELOG id: changelog run: | @@ -134,7 +145,11 @@ jobs: - name: Publish if: env.all_pass == 'true' run: | + # create .env + echo "NPM_TOKEN=${{ secrets.NPM_TOKEN }}" > .env # publish - yarn npm publish --access=public --no-git-checks + sh .script/publish.sh + # remove .env + rm .env env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/update-version-from-comment.yml b/.github/workflows/update-version-from-comment.yml index c819285..46cfc93 100644 --- a/.github/workflows/update-version-from-comment.yml +++ b/.github/workflows/update-version-from-comment.yml @@ -189,14 +189,6 @@ jobs: env: GH_TOKEN: ${{ github.token }} run: | - # 최근 태그 확인 후 로컬 및 원격 태그 삭제 - LATEST_TAG=$(git tag | sort -V | tail -n 1) - if [ ! -z "$LATEST_TAG" ]; then - echo "최근 태그 삭제: $LATEST_TAG" - git tag -d $LATEST_TAG - git push --delete origin $LATEST_TAG || echo "원격 태그가 없거나 삭제 권한이 없습니다." - fi - # checkout auto-changelog-update branch git config --global user.name "GitHub Actions Bot" git config --global user.email "github-actions[bot]@users.noreply.github.com" @@ -208,12 +200,6 @@ jobs: UPDATE_VERSION=${{steps.extract-version.outputs.VERSION}} - # 최근 커밋 revert 하기 - git revert HEAD --no-commit - - # discard changes - git reset --hard - # nightly 버전 업데이트 if [[ "$UPDATE_VERSION" == "nightly" ]]; then # 이전 버전 [x].[y].[z] 추출 @@ -258,8 +244,42 @@ jobs: echo "Update version: $UPDATE_VERSION" fi - yarn release --release-as $UPDATE_VERSION + # CHANGELOG.md 파일 업데이트 + TODAY=$(date +%Y-%m-%d) + # 첫 번째 릴리즈 태그 라인 찾기 + FIRST_TAG_LINE=$(grep -n "^### \[" CHANGELOG.md | head -1 | cut -d':' -f1) + if [[ -n "$FIRST_TAG_LINE" ]]; then + # 현재 릴리즈 태그 정보 추출 + CURRENT_TAG_LINE=$(sed -n "${FIRST_TAG_LINE}p" CHANGELOG.md) + + # 현재 버전 추출 + CURRENT_VERSION=$(echo "$CURRENT_TAG_LINE" | grep -o '\[.*\]' | sed 's/\[\(.*\)\]/\1/') + echo "현재 버전: $CURRENT_VERSION" + + # 이전 버전 추출 (compare 부분에서) + PREVIOUS_VERSION=$(echo "$CURRENT_TAG_LINE" | grep -o 'compare/v[^\.]*\.[^\.]*\.[^\.]*' | sed 's/compare\/v//') + echo "이전 버전: $PREVIOUS_VERSION" + + # 새로운 릴리즈 태그 라인 생성 + NEW_TAG_LINE="### [${UPDATE_VERSION}](https://github.com/ummgoban/shared/compare/v${PREVIOUS_VERSION}...v${UPDATE_VERSION}) (${TODAY})" + echo "새 태그 라인: $NEW_TAG_LINE" + + # 첫 번째 릴리즈 태그 라인 교체 + sed -i.bak "${FIRST_TAG_LINE}s|.*|${NEW_TAG_LINE}|" CHANGELOG.md + rm -f CHANGELOG.md.bak + echo "CHANGELOG.md 파일이 업데이트되었습니다." + + # package.json 버전 업데이트 + sed -i.bak "s/\(\"version\":\) \".*\"/\1 \"${UPDATE_VERSION}\"/" package.json + rm -f package.json.bak + echo "package.json 파일이 업데이트되었습니다." + else + echo "CHANGELOG.md 파일에서 릴리즈 태그를 찾을 수 없습니다." + fi + git add CHANGELOG.md package.json + git commit -m "docs: update CHANGELOG.md and package.json for v${UPDATE_VERSION}" + git push origin auto-changelog-update # pull request 이름 변경 @@ -275,6 +295,6 @@ jobs: with: issue-number: ${{ github.event.issue.number }} body: | - @${{ github.event.comment.user.login }} 버전 업데이트가 완료되었습니다! ✅ + @${{ github.event.comment.user.login }} 버전 업데이트가 완료되었습니다! 버전: ${{ steps.extract-version.outputs.VERSION }} diff --git a/.script/publish-local.sh b/.script/publish.sh similarity index 81% rename from .script/publish-local.sh rename to .script/publish.sh index 6bab0c6..4ac92a4 100755 --- a/.script/publish-local.sh +++ b/.script/publish.sh @@ -5,6 +5,6 @@ sh .script/pre-install.sh -yarn npm publish --access=public +yarn npm publish --access=public --no-git-checks sh .script/post-install.sh diff --git a/package.json b/package.json index 3f20865..5194614 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "format:check": "prettier --check src", "test:all": "yarn lint:check && yarn format:check && yarn type-check && yarn test", "release": "standard-version", - "publish:local": "sh ./.script/publish-local.sh", + "publish": "sh ./.script/publish.sh", "storybook": "storybook dev -p 6006", "build-storybook": "storybook build" },