diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 3482125..6413a74 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,24 +1,30 @@ name: publish -# GitHub Release를 publish하면 npm에 배포한다. NPM_TOKEN 시크릿 필요. +# GitHub Release를 publish하면 npm에 배포한다. +# 인증은 npm Trusted Publishing(OIDC) — 장기 토큰(NPM_TOKEN) 없이 단기 토큰으로 배포하며 +# provenance도 자동 생성된다. npm 쪽 패키지 설정에 이 저장소·워크플로가 등록돼 있어야 한다. on: release: types: [published] permissions: contents: read - id-token: write # npm provenance(OIDC)에 필요 + id-token: write # OIDC 토큰 발급에 필요 jobs: publish: - runs-on: ubuntu-latest + runs-on: ubuntu-latest # Trusted Publishing은 GitHub-hosted 러너만 지원 steps: - uses: actions/checkout@v4 + with: + persist-credentials: false # 배포에 repo 자격증명이 필요 없다 — git config에 남기지 않는다 - uses: actions/setup-node@v4 with: - node-version: 20 + node-version: 24 # OIDC 요구: node 22.14+ / npm 11.5.1+ registry-url: https://registry.npmjs.org + # setup-node가 .npmrc에 남기는 _authToken placeholder가 OIDC 인증과 충돌할 수 있어 + # Trusted Publishing을 지원하는 npm으로 고정한다(11.5.1+). id-token 권한이 있는 job이므로 + # 가변 태그(@latest) 대신 버전을 핀하고 설치 스크립트도 실행하지 않는다 + - run: npm install -g --ignore-scripts npm@11.8.0 - run: npm ci - run: npm test - - run: npm publish --provenance - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + - run: npm publish