Skip to content

ci(publish): GCP Artifact Registry への publish を導入する#4

Open
april418 wants to merge 2 commits into
masterfrom
feature/publish-to-artifact-registry
Open

ci(publish): GCP Artifact Registry への publish を導入する#4
april418 wants to merge 2 commits into
masterfrom
feature/publish-to-artifact-registry

Conversation

@april418
Copy link
Copy Markdown
Contributor

Summary

npm registry への手動 publish 運用から、IMUID-js と同じ
asia-northeast1 の Artifact Registry (intimatemerger プロジェクト
配下の `npm-intimatemerger-internal` repo) への自動 publish に
切り替えるのだ。

リファレンス:
IntimateMerger/IMUID-js/.github/workflows/publish-to-artifactregistry.yml

migration PR (#1) とは独立した PR として進めるのだ。
マージ順序は問わないが、AR publish が動くのは pnpm 移行とは無関係なので
こちらだけ先にマージしても問題ないのだ。

Changes

  • `.npmrc` を新規追加 (scope mapping)
  • `package.json`:
    • `name` を `@intimatemerger/im-ulid` → `@intimatemerger-internal/im-ulid` にリネーム
    • `files` フィールドを `["dist"]` に明示 (これまでは未指定で repo 全体が publish 対象)
    • `artifactregistry-login` script を追加 (`npx google-artifactregistry-auth`)
  • `.github/workflows/publish-to-artifactregistry.yml` を新規追加:
    • master push と workflow_dispatch がトリガ
    • WIF 経由で SA を impersonate (`vars.WORKLOAD_IDENTITY_PROVIDER` /
      `vars.WORKLOAD_IDENTITY_SERVICE_ACCOUNT`)
    • `yarn install --immutable` → `yarn run build` →
      `yarn run artifactregistry-login` → `yarn publish --non-interactive --no-git-tag-version`
    • test.yml と同じ NODE_OPTIONS=--openssl-legacy-provider を env に
      置く (webpack 5.44 が node 17+ で落ちる対策)
    • action SHA は IM ポリシーに合わせて pinact 済み

マージ前に必要な GCP / GitHub 設定

リポジトリ admin / GCP admin が以下を実施する必要があるのだ:

GCP 側

  1. SA 作成 (`gcloud iam service-accounts create im-ulid-github-actions`)
  2. SA に `roles/artifactregistry.writer` 付与 (AR repo の IAM)
  3. SA に shared WIF Pool から `roles/iam.workloadIdentityUser` 付与
    (principalSet で `IntimateMerger/im-ulid` repo 全体に対して)

GitHub 側

`Settings > Variables > Actions` で:

詳細手順は監査リポの AR_PUBLISH_SETUP.md (社内 doc) を参照するのだ。

Test plan

  • 設定完了後、master へマージして `Publish to ArtifactRegistry` workflow が走ることを確認
  • AR コンソールで `@intimatemerger-internal/im-ulid@0.0.6` が登録されることを確認
  • 下流リポ (trust360 等) の依存切り替えは別 PR で対応

Co-Authored-By: Claude noreply@anthropic.com

april418 and others added 2 commits May 30, 2026 00:50
npm registry への手動 publish 運用から、IMUID-js と同じ
asia-northeast1 の Artifact Registry (intimatemerger プロジェクト
配下の npm-intimatemerger-internal repo) への自動 publish に
切り替える。master push をトリガにして WIF 経由で認証 → build →
google-artifactregistry-auth で .npmrc に token を埋める →
yarn publish の流れにする。

合わせて以下を整理する:

- package.json の name を @intimatemerger/im-ulid から
  @intimatemerger-internal/im-ulid にリネーム。下流リポ
  (trust360 / im-cmp / IMUID-js / gpt-secure-signal-provider-js /
  beacon.js) は別途 @intimatemerger-internal/im-ulid への switch が
  必要なのだ。
- files フィールドを ["dist"] に明示。これまでは未指定で repo 全体が
  publish 対象に含まれていたが、AR には dist/ だけ載れば十分なので
  payload を最小化する。

NODE_OPTIONS=--openssl-legacy-provider は test.yml と同じ理由
(webpack 5.44 が node 17+ で ERR_OSSL_EVP_UNSUPPORTED で落ちる)
で env に置く。migration PR で webpack 5.105+ に上がれば不要に
なる。

GitHub repo 側の設定 (WORKLOAD_IDENTITY_PROVIDER /
WORKLOAD_IDENTITY_SERVICE_ACCOUNT vars) と GCP 側の AR 権限・
SA 作成は本コミットの範囲外。マージ前にリポジトリ admin が
設定する想定なのだ。

Co-Authored-By: Claude <noreply@anthropic.com>
GitHub repo の Actions vars に依存する形だと設定漏れで失敗するため、
リポ admin が GitHub 側で vars を仕込む手間を省く目的で、共有の
WIF provider (intimatemerger-access の github-actions-pool) と
共有の SA (gha-artifactregistry@intimatemerger.iam.gserviceaccount.com)
をワークフローに直接書き込む。

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant