릴리즈: 0.0.13 - 게시 관문에 막힌 0.0.12를 대체한다 #11
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 | |
| jobs: | |
| # 게시는 되돌릴 수 없다(버전 번호 재사용 불가). 그래서 ci의 게이트 집합 전부를 통과해야 한다. | |
| # 목록을 여기 복사하지 않는 이유: 복사본은 ci가 자랄 때 조용히 뒤처진다. | |
| gates: | |
| permissions: | |
| contents: read | |
| uses: ./.github/workflows/ci.yml | |
| publish: | |
| needs: gates | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write # npm Trusted Publishing OIDC는 게시 job에만 연다. | |
| steps: | |
| # 태그 확인을 위해 전체 이력을 받는다(dispatch 경로는 ref가 태그가 아니다). | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7 | |
| 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@11.19.0 | |
| # 릴리즈 정책: package.json 버전과 태그는 항상 같은 값이다. 어긋나면 여기서 멈춘다 | |
| # (태그만 앞서 나가 엉뚱한 버전이 게시되는 사고 방지). 이 검증에는 조건을 걸지 않는다: | |
| # 예전에는 태그 push에서만 돌아서 workflow_dispatch가 검증을 건너뛰고 게시까지 갔다. | |
| - name: 태그와 package.json 버전 일치 검증 | |
| run: | | |
| set -eu | |
| pkgVersion="$(node -p "require('./package.json').version")" | |
| case "$GITHUB_REF" in | |
| refs/tags/*) | |
| tagVersion="${GITHUB_REF_NAME#v}" | |
| echo "tag=$tagVersion package.json=$pkgVersion" | |
| test "$tagVersion" = "$pkgVersion" | |
| ;; | |
| *) | |
| # dispatch 경로: 체크아웃한 커밋에 v<pkgVersion> 태그가 붙어 있어야 한다. | |
| # 릴리즈 = 버전 +1 + 버전 태그가 같은 커밋에 있다는 규칙의 집행 지점이다. | |
| echo "dispatch: package.json=$pkgVersion, HEAD 태그 목록:" | |
| git tag --points-at HEAD | |
| git tag --points-at HEAD | grep -Fxq "v$pkgVersion" | |
| ;; | |
| esac | |
| - run: npm ci | |
| - run: npm publish |