From ea8f4c4f485485b3df502feade522afc9c0b994b Mon Sep 17 00:00:00 2001 From: juunghyun Date: Wed, 8 Jul 2026 16:02:15 +0900 Subject: [PATCH] =?UTF-8?q?chore(ci):=20GitHub=20Actions=20CI=C2=B7?= =?UTF-8?q?=EB=A6=B4=EB=A6=AC=EC=A6=88=20=EC=9E=90=EB=8F=99=ED=99=94=20?= =?UTF-8?q?=EC=9B=8C=ED=81=AC=ED=94=8C=EB=A1=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 지금까지 CI가 전혀 없어 테스트·빌드 검증이 로컬 수동에 의존했고, npm 배포도 git 태그 없이 수동으로 이뤄져 npm 버전과 코드 시점의 매핑이 남지 않았다(0.2.0 태그 부재). v0.3.0부터는 태그 push 한 번으로 검증→npm publish→GitHub Release 생성까지 자동으로 흐르게 하고, PR마다 빌드·타입체크·테스트가 게이트로 돈다. * .github/workflows/ci.yml: PR·main push 시 node 20/24 매트릭스로 npm ci → build → tsc --noEmit → vitest 실행 -> engines 최소선(20)과 최신 LTS(24) 양쪽에서 회귀를 머지 전에 차단 * .github/workflows/release.yml: v* 태그 push 시 태그↔package.json 버전 가드 → 검증 → npm publish(Trusted Publishing OIDC, provenance) → gh release create --generate-notes -> 토큰 시크릿 관리 없이 태그 한 번으로 배포+릴리즈 완결, 버전 불일치 태그는 배포 전에 실패 * 인증 전제: npmjs.com termfc 패키지 설정에 GitHub Actions(juunghyun/termfc, release.yml) trusted publisher 등록 필요 — 워크플로 주석에 명시 테스트: python3 yaml.safe_load / npx js-yaml로 두 파일 문법 검증 통과. 워크플로 실제 실행은 로컬 불가 — not-run, 이 브랜치의 PR 생성 시 ci.yml이 자체 검증됨 --- .github/workflows/ci.yml | 23 ++++++++++++++++++ .github/workflows/release.yml | 44 +++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..753ee98 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,23 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + node: [20, 24] # 20 = engines 최소 지원선, 24 = 최신 LTS + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node }} + cache: npm + - run: npm ci + - run: npm run build + - run: npx tsc --noEmit + - run: npm test diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..f0ac1af --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,44 @@ +name: Release + +# v* 태그 push → 테스트 → npm publish → GitHub Release 생성. +# npm 인증은 Trusted Publishing(OIDC) 전제 — npmjs.com의 termfc 패키지 설정에서 +# GitHub Actions(juunghyun/termfc, release.yml)를 trusted publisher로 등록해야 한다. +on: + push: + tags: ["v*"] + +permissions: + contents: write # GitHub Release 생성 + id-token: write # npm Trusted Publishing(OIDC) + provenance + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 24 # npm >= 11.5 (trusted publishing 지원) + registry-url: https://registry.npmjs.org + cache: npm + - run: npm ci + + - name: Guard — 태그와 package.json 버전 일치 확인 + run: | + pkg="v$(node -p "require('./package.json').version")" + if [ "$pkg" != "$GITHUB_REF_NAME" ]; then + echo "::error::tag $GITHUB_REF_NAME != package.json $pkg" + exit 1 + fi + + - run: npm run build + - run: npx tsc --noEmit + - run: npm test + + # prepublishOnly(build + test)가 한 번 더 돌지만 안전망으로 그대로 둔다 + - run: npm publish + + - name: GitHub Release 생성 + env: + GH_TOKEN: ${{ github.token }} + run: gh release create "$GITHUB_REF_NAME" --generate-notes --verify-tag