自動化發佈會在你推送版本標籤或手動啟動 GitHub Actions 工作流程時,建置並發佈沙箱外掛。你的 Atmosphere 帳戶 仍擁有套件設定檔與發佈記錄。GitHub 識別已核准的工作流程,發佈服務驗證建置,並透過狹窄的委託寫入發佈記錄。儲存庫不會儲存 Atmosphere 帳戶憑證。
從你的電腦啟動發佈時,使用 emdash-plugin publish。當應由 GitHub Actions 建置並發佈時,使用本指南。
先決條件
開始前請準備:
- 包含沙箱 EmDash 外掛的公開 GitHub 儲存庫。
- 作為開發相依性安裝的
@emdash-cms/plugin-cli。用 CLI 建立的外掛已包含它。 - 有效的
emdash-plugin.jsonc,包含slug、publisher、license、作者與安全性聯絡人。將repo設為規範 GitHub URL,或在互動式設定中確認偵測到的 GitHub 遠端。 package.json中的版本,或僅註冊表外掛的emdash-plugin.jsonc中的版本。publisher所指定的 Atmosphere 帳戶。- 支援通行密鑰的瀏覽器。發佈核准需要使用者驗證。
在設定工作流程之前執行清單檢查:
pnpm exec emdash-plugin validate
設定自動化發佈
-
使用擁有該套件的 Atmosphere 帳戶登入外掛 CLI。
pnpm exec emdash-plugin login alice.example.comCLI 將此本機發佈工作階段儲存在專案之外。GitHub Actions 永遠不會收到它。
-
從外掛目錄準備套件設定檔並產生工作流程。
pnpm exec emdash-plugin release setup該命令從
emdash-plugin.jsonc讀取套件中繼資料。若缺少套件設定檔,會提議建立。若設定檔存在但沒有 delegated-release 設定,會提議新增它們,同時保留現有套件中繼資料。在 monorepo 中,在外掛套件內執行該命令,或傳入
--dir <plugin-directory>。若清單不含repo,設定會偵測 GitHuborigin遠端並預填儲存庫提示。設定會詢問何時需要核准發佈:
- When plugin permissions increase 為預設。當宣告的存取相對最新發佈擴大時,發佈會等待核准。
- For every release 要求每個版本都經核准。
設定還會詢問發佈是否需要可驗證的 provenance。自動化發佈的預設是 Require provenance。僅當同一設定檔還必須接受從可信本機環境直接發佈的版本時,才選擇 Allow releases without provenance。
已登入的 Atmosphere 帳戶成為初始核准者。設定檔將套件繫結到規範 GitHub 儲存庫 URL,並記錄所選的 provenance 原則。
當工作流程檔案已存在時,僅執行設定檔步驟:
pnpm exec emdash-plugin profile setup發佈套件設定檔後,此命令會顯示手動與 GitHub Actions 發佈命令。
在非互動式終端機中,傳入
--yes以接受預設原則。當清單與 Git 遠端都未提供儲存庫時傳入--repository <https-url>,傳入--provenance optional以允許無 provenance 的發佈,傳入--confirmation always以要求每次發佈都經核准。 -
審查並提交產生的工作流程。
該命令建立
.github/workflows/emdash-release.yml。它不會推送該檔案,除非傳入--force,否則不會取代現有工作流程。若儲存庫包含
.changeset/config.json,互動式設定會提供 Follow Changesets releases。當 Changesets 發佈包含emdash-plugin.jsonc的套件時,可複用的 EmDash 工作流程會發佈相同版本。如下所述將其連線到現有 Changesets 工作流程。否則,產生的工作流程會針對符合<slug>@<version>的套件標籤執行。兩種變體都支援手動執行,並可用--trigger changesets|tags|manual明確選擇。工作流程僅為每個作業授予所需的
contents、id-token與attestations權限;將第三方 Actions 固定到完整認可識別碼;執行產生該檔案的確切外掛 CLI 版本;從清單解析每個套件;建置一個外掛套件;為這些確切位元組建立 GitHub 建置 provenance;並將兩個檔案傳給 EmDash 發佈 Action。工作流程位於儲存庫根目錄,並由該儲存庫中的每個外掛套件共用。從巢狀套件執行
release setup仍會在根目錄寫入.github/workflows/emdash-release.yml。 -
開啟 發佈服務儀表板,使用同一 Atmosphere 帳戶登入。
選擇 Authorize publishing。你的帳戶提供者會顯示確切的委託權限。保留的授權可以建立套件發佈記錄並上傳套件或列表圖片 blob。它不能建立或編輯套件設定檔、更新或刪除發佈,或寫入其他集合。
-
啟動發佈工作流程。
使用 Changesets 時,合併版本提取要求並讓其發佈作業完成。Changesets Action 會將其發佈的套件傳給可複用的 EmDash 工作流程。普通 npm 套件會被忽略;包含
emdash-plugin.jsonc的套件會向 EmDash 發佈相同版本。使用套件標籤觸發器時,在建立版本標籤之前更新套件版本。以下命令啟動
1.2.3發佈:git tag gallery@1.2.3 git push origin gallery@1.2.3你也可以在儲存庫的 GitHub Actions 頁面上選擇 Run workflow。
-
在首次執行時核准每個儲存庫 ref 範圍。
服務在建立連線要求之前驗證發起套件設定檔是否指定了 GitHub 儲存庫。Action 會在 GitHub 作業摘要中寫入連結並等待。開啟連結並確認儲存庫、工作流程檔案、分支或標籤以及環境。
對於由標籤觸發的執行,選擇 All package version tags 或 Only this tag。手動執行在首次使用其分支時要求核准。確認另一個標籤或分支範圍會將其新增到儲存庫連線,而不會移除現有範圍。服務儲存 GitHub 儲存庫與擁有者 ID,以及已核准的 ref 與環境。後續套件僅在其簽名設定檔指定同一儲存庫時才會複用這些範圍。
由較舊產生工作流程建立的套件核准仍限於其原始套件。第一個不符合的套件或 ref 會要求儲存庫連線;服務不會自動擴大現有套件核准。
-
在需要時核准發佈。
擴大外掛權限的發佈,或設定為每次發佈都確認的設定檔,會進入 Awaiting approval。從 Action 輸出或發佈儀表板開啟核准 URL。若核准帳戶尚無通行密鑰則註冊一個,審查權限變更,並核准或拒絕該發佈。
預設 Action 設定在發佈達到 Awaiting approval 時成功回傳。服務工作流程繼續等待瀏覽器決定,並在核准後發佈。
連線 Changesets 工作流程
產生的 .github/workflows/emdash-release.yml 透過 workflow_call 接受 Changesets Action 的已發佈套件 JSON。向現有 Changesets 作業新增輸出,然後從相依作業呼叫 EmDash 工作流程。當現有作業或步驟使用其他 ID 時,取代 release 與 changesets。
Changesets Action v2 使用 published-packages 輸出。將以下作業輸出與呼叫方新增到使用 Changesets CLI v3 的工作流程:
jobs:
release:
# Keep the existing runner, permissions, and steps.
outputs:
published: ${{ steps.changesets.outputs.published }}
published-packages: ${{ steps.changesets.outputs['published-packages'] }}
publish-emdash-plugins:
needs: release
if: needs.release.outputs.published == 'true'
uses: ./.github/workflows/emdash-release.yml
with:
published-packages: ${{ needs.release.outputs['published-packages'] }}
permissions:
contents: read
id-token: write
attestations: write
Changesets Action v1 使用 camel-case 的 publishedPackages 步驟輸出。對使用 Changesets CLI v2 的工作流程使用此運算式:
jobs:
release:
# Keep the existing runner, permissions, and steps.
outputs:
published: ${{ steps.changesets.outputs.published }}
published-packages: ${{ steps.changesets.outputs.publishedPackages }}
publish-emdash-plugins:
needs: release
if: needs.release.outputs.published == 'true'
uses: ./.github/workflows/emdash-release.yml
with:
published-packages: ${{ needs.release.outputs['published-packages'] }}
permissions:
contents: read
id-token: write
attestations: write
讓 Changesets 負責其版本提取要求與套件發佈。僅當 Changesets 回報 published: true 時,EmDash 呼叫方才執行。對於僅 EmDash 的私人套件,在 .changeset/config.json 中將 privatePackages.version 與 privatePackages.tag 都設為 true。將無關的私人應用程式與測試固定裝置加入 ignore。
新增另一個套件
從其來源目錄準備套件設定檔。現有根工作流程與儲存庫連線會被複用:
pnpm exec emdash-plugin profile setup --dir packages/comments
使用 Changesets 時,將該套件加入 changeset 並合併其版本提取要求。使用套件標籤觸發器時,更新套件版本並推送其標籤:
git tag comments@1.0.0
git push origin comments@1.0.0
工作流程將 comments 解析為一個 emdash-plugin.jsonc,檢查所選版本,並在接受成品上傳之前驗證簽名設定檔是否指定了已連線的儲存庫。重複的套件 ID 與版本不符合會在 attestation 之前失敗。
發佈服務驗證什麼
服務在寫入發佈之前完成這些檢查:
- GitHub OpenID Connect (OIDC) 權杖指定了已授權的儲存庫、擁有者、工作流程、ref、環境、認可、執行與 GitHub 託管的執行器。
- 套件設定檔存在,由發佈者簽名,包含 delegated-release 設定,並指定同一規範 GitHub 儲存庫。
- 要求的套件與版本與已建置的外掛套件相符。
- 套件總和檢查與上傳的位元組相符。
- GitHub provenance 涵蓋同一套件、儲存庫、工作流程、認可與執行。
- 發佈記錄宣告的存取與套件清單相符。
- 版本記錄尚不存在。
- 任何所需的通行密鑰核准涵蓋確切的驗證結果與目前設定檔修訂。
Action 為每次服務呼叫要求新的 GitHub OIDC 權杖。僅在工作流程獲授權後,套件與 provenance 檔案才進入私人瞬時儲存。服務將已驗證的套件與圖片位元組上傳到發佈者的個人資料伺服器 (PDS),在那裡建立發佈記錄,並透過不可變的總和檢查定址 URL 公開已驗證的 provenance。
權限邊界
每種憑證各司其職:
| Credential | Used by | Authority |
|---|---|---|
| Local CLI OAuth session | emdash-plugin profile setup | Create or update the publisher-owned package profile after local confirmation. |
| GitHub OIDC token | Release Action | Identify one GitHub workflow run to the service. It grants no AT Protocol write access. |
| Release-service delegation | Release service | Create package release records and upload the required blobs. |
| Publisher application session | Release dashboard | Authorise workflow connections and revoke delegated publishing. |
| Approver session and passkey | Approval page | Approve or reject one checksum-bound release verification. |
| Cloudflare Access identity | Service operator console | Operate the hosted service. It does not represent a publisher or approver. |
服務分別儲存發佈者與核准者狀態。登入檢視你的發佈不會授予營運存取,營運身分也不能以發佈者身分核准發佈。
Action 行為
產生的工作流程使用 apps/release-action 中的 Action。Action 接受已建置的套件加原始 Sigstore provenance,或包含總和檢查繫結 HTTPS 成品來源的相容 release-file。不要將 release-file 與套件或 provenance 輸入組合。
標準產生工作流程提供這些輸入。在此顯示是為了讓你審查產生的檔案,而無需推斷每個值授權什麼:
| Input | Value |
|---|---|
service-url | Release-service HTTPS origin. |
publisher-did | DID that owns the package profile and releases. |
bundle-file | The single tarball produced by emdash-plugin release prepare. |
provenance-file | Raw bundle-path output from actions/attest-build-provenance. |
Action 回傳這些輸出:
| Output | Meaning |
|---|---|
connection-url | Browser URL for first-run workflow approval. |
intent-id | Release intent identifier. |
state | Published, terminal, or awaiting_approval state. |
approval-url | Browser URL when passkey approval is required. |
release-uri | Published release AT URI. |
release-cid | Published release record CID. |
reason-code | Stable reason for a terminal intent. |
有關選用輸入、自訂 URL 來源工作流程、輪詢控制與確切輸出行為,請參見 Action 參考。
疑難排解
PACKAGE_PROFILE_REQUIRED
套件設定檔缺失、缺少 delegated-release 設定、使用非規範儲存庫 URL,或指定了與 GitHub 工作流程不同的儲存庫。
使用發佈者帳戶在本機執行設定檔設定,然後重新啟動工作流程:
pnpm exec emdash-plugin profile setup
此檢查在服務接受套件或 provenance 上傳之前執行。
需要公開儲存庫
GitHub 對私人與內部儲存庫使用私人 Sigstore 信任根。發佈驗證器目前僅信任公開 GitHub provenance。將發佈工作流程移到公開儲存庫,或使用 emdash-plugin publish 本機發佈。
WORKLOAD_NOT_ALLOWED
GitHub 儲存庫、擁有者、工作流程檔案、ref 或環境與已核准的工作流程原則不符合。開啟發佈儀表板,以預期範圍核准新的工作流程連線。
PROFILE_FETCH_FAILED
服務無法從發佈者的 PDS 驗證設定檔。在帳戶提供者可用後重試。若設定檔被移除或變更,執行 emdash-plugin profile setup。
POLL_TIMEOUT
Action 在工作流程核准、發佈核准或發佈完成之前達到了 timeout-minutes。重新執行前在發佈儀表板中檢查 intent 狀態。同一 GitHub Actions 執行的重新執行會複用其冪等金鑰。
撤銷自動化發佈
在發佈儀表板中選擇 Turn off automated publishing。撤銷會清除保留的發佈委託。現有套件設定檔、發佈、審核標籤、已安裝外掛與儀表板登入不會變更。
在下一次自動化發佈之前,重新連線發佈並再次核准工作流程。
相關文件
- Bundling and publishing 涵蓋本機發佈與套件驗證。
- The plugin manifest 定義套件中繼資料與宣告的存取。
- Capabilities and security 說明在發佈核准與安裝期間審查的權限。
- The plugin registry 說明探索、審核與安裝驗證。