publish #5
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # npm 퍼블리시: 버전 태그(v0.0.x) 푸시가 트리거. 릴리즈 절차의 마지막 단계를 자동화한다. | |
| # 정본 절차는 docs/operations/release.md (여기는 집행만). | |
| # | |
| # 인증은 npm Trusted Publishing(OIDC)이다. 장수 토큰(NPM_TOKEN 시크릿)을 두지 않는다: | |
| # 러너가 GitHub OIDC로 자기 신원을 증명하고 npm이 단기 자격을 발급한다. 유출될 비밀이 | |
| # 없고 provenance(출처 증명)가 자동으로 붙는다. 사전 1회 설정이 필요하다: | |
| # npmjs.com > pyproc > Settings > Trusted Publisher > GitHub Actions | |
| # (repository: eddmpython/pyproc, workflow: publish.yml) | |
| name: publish | |
| on: | |
| push: | |
| tags: ["v*"] | |
| # 수동 실행. 태그가 워크플로보다 먼저 나갔거나 게시가 실패해 재시도할 때 쓴다. | |
| # 게시 버전은 언제나 체크아웃한 ref의 package.json이다. | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| id-token: write # OIDC 신원 증명. 이게 없으면 trusted publishing이 성립하지 않는다. | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| registry-url: https://registry.npmjs.org | |
| # trusted publishing은 npm >= 11.5.1에서만 동작한다(node 22 번들은 10.x). | |
| - run: npm install -g npm@latest | |
| # 릴리즈 정책: package.json 버전과 태그는 항상 같은 값이다. 어긋나면 여기서 멈춘다 | |
| # (태그만 앞서 나가 엉뚱한 버전이 게시되는 사고 방지). | |
| - name: 태그와 package.json 버전 일치 검증 | |
| if: startsWith(github.ref, 'refs/tags/') | |
| run: | | |
| tagVersion="${GITHUB_REF_NAME#v}" | |
| pkgVersion="$(node -p "require('./package.json').version")" | |
| echo "tag=$tagVersion package.json=$pkgVersion" | |
| test "$tagVersion" = "$pkgVersion" | |
| # 게이트 없이 게시하지 않는다. 퍼블리시는 되돌릴 수 없다(버전 번호 재사용 불가). | |
| - run: npm test | |
| - run: npm run test:browser | |
| env: | |
| PYPROC_BROWSER: /usr/bin/google-chrome | |
| - run: npm publish |