From d902d49068d167c3c1c6d1d0ed80a27b2c52e213 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=8B=AC=EC=9C=A0=EC=A7=84?= Date: Sun, 16 Nov 2025 20:37:44 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20merge,=20create=20PR=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/bump-pr.yaml | 60 +++++++++++++++++++ ...to-bump-version.yaml => bump-version.yaml} | 47 ++------------- 2 files changed, 66 insertions(+), 41 deletions(-) create mode 100644 .github/workflows/bump-pr.yaml rename .github/workflows/{auto-bump-version.yaml => bump-version.yaml} (79%) diff --git a/.github/workflows/bump-pr.yaml b/.github/workflows/bump-pr.yaml new file mode 100644 index 0000000..fad9180 --- /dev/null +++ b/.github/workflows/bump-pr.yaml @@ -0,0 +1,60 @@ +name: Create & Merge Bump PR + +on: + push: + branches: + - 'bump/*' + +permissions: + contents: write + pull-requests: write + +jobs: + create-pr: + runs-on: ubuntu-latest + steps: + - name: Create PR + id: cpr + uses: actions/github-script@v7 + with: + script: | + const branch = context.ref.replace('refs/heads/', ''); + + const pr = await github.rest.pulls.create({ + owner: context.repo.owner, + repo: context.repo.repo, + title: 'chore: bump version & sync exports', + head: branch, + base: 'main' + }); + + core.setOutput('pr_number', pr.data.number); + + - name: Auto-merge PR + uses: actions/github-script@v7 + with: + script: | + await github.rest.pulls.merge({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: ${{ steps.cpr.outputs.pr_number }} + }); + + - name: Checkout merged main + uses: actions/checkout@v4 + with: + ref: main + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: '20' + registry-url: 'https://registry.npmjs.org' + + - name: Install dependencies + run: npm ci + + - name: Publish to npm + run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/auto-bump-version.yaml b/.github/workflows/bump-version.yaml similarity index 79% rename from .github/workflows/auto-bump-version.yaml rename to .github/workflows/bump-version.yaml index 3d30d27..c8499ce 100644 --- a/.github/workflows/auto-bump-version.yaml +++ b/.github/workflows/bump-version.yaml @@ -1,4 +1,4 @@ -name: Auto Bump Version on Merge to main +name: Bump Version on Merge to main on: pull_request: @@ -7,14 +7,12 @@ on: permissions: contents: write - pull-requests: write jobs: bump-version: if: > github.event.pull_request.merged == true && - github.event.pull_request.base.ref == 'main' && - github.actor != 'github-actions[bot]' + github.event.pull_request.base.ref == 'main' runs-on: ubuntu-latest steps: - name: Checkout main @@ -27,7 +25,6 @@ jobs: uses: actions/setup-node@v4 with: node-version: '20' - registry-url: 'https://registry.npmjs.org' - name: Detect if package.json version changed in PR id: ver_changed @@ -102,7 +99,7 @@ jobs: - name: Install dependencies run: npm ci - - name: Sync exports to src/shared/index.ts + - name: Sync exports (inline) run: | node -e " const fs = require('fs'); @@ -154,7 +151,7 @@ jobs: - name: Build package run: npm run build - - name: Create branch and commit + - name: Create bump branch and push run: | TIMESTAMP=$(date -u +'%Y%m%d-%H%M%S%N' | cut -c1-14) BRANCH="bump/$TIMESTAMP" @@ -162,7 +159,7 @@ jobs: git checkout -b "$BRANCH" if git diff --quiet; then - echo "No changes to commit." + echo "NO_CHANGES=true" >> $GITHUB_ENV exit 0 fi @@ -170,39 +167,7 @@ jobs: git config user.email "github-actions[bot]@users.noreply.github.com" git add . - git commit -m "chore: bump version and sync shared exports" + git commit -m "chore: bump version and sync exports" git push origin "$BRANCH" echo "BRANCH_NAME=$BRANCH" >> $GITHUB_ENV - - - name: Create PR - id: cpr - uses: actions/github-script@v7 - with: - script: | - const branch = process.env.BRANCH_NAME; - - const pr = await github.rest.pulls.create({ - owner: context.repo.owner, - repo: context.repo.repo, - title: 'chore: bump version & sync exports', - head: branch, - base: 'main' - }); - - core.setOutput('pr_number', pr.data.number); - - - name: Auto-merge PR - uses: actions/github-script@v7 - with: - script: | - await github.rest.pulls.merge({ - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: ${{ steps.cpr.outputs.pr_number }} - }); - - - name: Publish to npm - run: npm publish - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}