@intentius/chant 0.124.62 → 0.124.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/handlers/approve.d.ts +26 -0
- package/dist/cli/handlers/approve.d.ts.map +1 -1
- package/dist/cli/handlers/approve.js +167 -18
- package/dist/cli/handlers/plan.d.ts +10 -0
- package/dist/cli/handlers/plan.d.ts.map +1 -0
- package/dist/cli/handlers/plan.js +71 -0
- package/dist/cli/handlers/pr.d.ts.map +1 -1
- package/dist/cli/handlers/pr.js +2 -1
- package/dist/cli/handlers/release.d.ts +11 -7
- package/dist/cli/handlers/release.d.ts.map +1 -1
- package/dist/cli/handlers/release.js +93 -20
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +48 -7
- package/dist/cli/mcp/workspace-tools.d.ts.map +1 -1
- package/dist/cli/mcp/workspace-tools.js +2 -1
- package/dist/cli/parse-args.d.ts.map +1 -1
- package/dist/cli/parse-args.js +43 -0
- package/dist/cli/registry.d.ts +18 -2
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/config.d.ts +50 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -0
- package/dist/gate-decision.d.ts +1 -1
- package/dist/gate-decision.d.ts.map +1 -1
- package/dist/gate-decision.js +4 -2
- package/dist/gate-statement.schema.json +46 -0
- package/dist/lifecycle/__fixtures__/publish-fakes.d.ts +20 -0
- package/dist/lifecycle/__fixtures__/publish-fakes.d.ts.map +1 -1
- package/dist/lifecycle/__fixtures__/publish-fakes.js +119 -3
- package/dist/lifecycle/gate-ledger.d.ts +28 -5
- package/dist/lifecycle/gate-ledger.d.ts.map +1 -1
- package/dist/lifecycle/gate-ledger.js +6 -0
- package/dist/lifecycle/gate-seal.d.ts +59 -7
- package/dist/lifecycle/gate-seal.d.ts.map +1 -1
- package/dist/lifecycle/gate-seal.js +68 -15
- package/dist/lifecycle/gate-statement.d.ts +95 -0
- package/dist/lifecycle/gate-statement.d.ts.map +1 -0
- package/dist/lifecycle/gate-statement.js +110 -0
- package/dist/lifecycle/gate-webauthn.d.ts +79 -0
- package/dist/lifecycle/gate-webauthn.d.ts.map +1 -0
- package/dist/lifecycle/gate-webauthn.js +105 -0
- package/dist/lifecycle/git.d.ts +1 -1
- package/dist/lifecycle/git.d.ts.map +1 -1
- package/dist/lifecycle/git.js +24 -19
- package/dist/lifecycle/ledger-remote.d.ts +37 -0
- package/dist/lifecycle/ledger-remote.d.ts.map +1 -0
- package/dist/lifecycle/ledger-remote.js +42 -0
- package/dist/lifecycle/plan-stale.d.ts +76 -0
- package/dist/lifecycle/plan-stale.d.ts.map +1 -0
- package/dist/lifecycle/plan-stale.js +120 -0
- package/dist/lifecycle/publish-credentials.d.ts +1 -1
- package/dist/lifecycle/publish-credentials.d.ts.map +1 -1
- package/dist/lifecycle/publish-credentials.js +2 -0
- package/dist/lifecycle/publish-declaration.d.ts +107 -0
- package/dist/lifecycle/publish-declaration.d.ts.map +1 -1
- package/dist/lifecycle/publish-declaration.js +110 -1
- package/dist/lifecycle/publish-forge.d.ts +5 -1
- package/dist/lifecycle/publish-forge.d.ts.map +1 -1
- package/dist/lifecycle/publish-forge.js +13 -4
- package/dist/lifecycle/publish-git-ssh.d.ts +82 -0
- package/dist/lifecycle/publish-git-ssh.d.ts.map +1 -0
- package/dist/lifecycle/publish-git-ssh.js +180 -0
- package/dist/lifecycle/publish-github.d.ts +69 -0
- package/dist/lifecycle/publish-github.d.ts.map +1 -0
- package/dist/lifecycle/publish-github.js +153 -0
- package/dist/lifecycle/publish-homebrew.d.ts +77 -0
- package/dist/lifecycle/publish-homebrew.d.ts.map +1 -0
- package/dist/lifecycle/publish-homebrew.js +265 -0
- package/dist/lifecycle/publish-marketplace.d.ts +85 -0
- package/dist/lifecycle/publish-marketplace.d.ts.map +1 -0
- package/dist/lifecycle/publish-marketplace.js +398 -0
- package/dist/lifecycle/publish-targets.d.ts +6 -0
- package/dist/lifecycle/publish-targets.d.ts.map +1 -1
- package/dist/lifecycle/publish-targets.js +15 -0
- package/dist/lifecycle/publish-tauri.d.ts +61 -0
- package/dist/lifecycle/publish-tauri.d.ts.map +1 -0
- package/dist/lifecycle/publish-tauri.js +181 -0
- package/dist/lifecycle/release-cut.d.ts +51 -5
- package/dist/lifecycle/release-cut.d.ts.map +1 -1
- package/dist/lifecycle/release-cut.js +165 -16
- package/dist/lifecycle/release-publish.d.ts +18 -2
- package/dist/lifecycle/release-publish.d.ts.map +1 -1
- package/dist/lifecycle/release-publish.js +5 -0
- package/dist/lifecycle/release-revocation.d.ts +4 -3
- package/dist/lifecycle/release-revocation.d.ts.map +1 -1
- package/dist/lifecycle/release-revocation.js +5 -4
- package/dist/lifecycle/release-store.d.ts +32 -0
- package/dist/lifecycle/release-store.d.ts.map +1 -1
- package/dist/lifecycle/release-store.js +11 -0
- package/dist/lifecycle/snapshot-store.d.ts.map +1 -1
- package/dist/lifecycle/snapshot-store.js +17 -9
- package/dist/lifecycle/test-passkey.d.ts +25 -0
- package/dist/lifecycle/test-passkey.d.ts.map +1 -0
- package/dist/lifecycle/test-passkey.js +39 -0
- package/dist/notify.d.ts +23 -3
- package/dist/notify.d.ts.map +1 -1
- package/dist/notify.js +8 -2
- package/dist/notify.schema.json +12 -3
- package/dist/op/gate.d.ts +1 -1
- package/dist/op/gate.d.ts.map +1 -1
- package/dist/op/gate.js +2 -1
- package/dist/pr-forge.d.ts +20 -0
- package/dist/pr-forge.d.ts.map +1 -1
- package/dist/pr-forge.js +87 -8
- package/dist/release-floors.d.ts +1 -1
- package/dist/release-floors.js +1 -1
- package/dist/wave-runtime.mjs +333 -331
- package/dist/workspace/ci-builds.d.ts +21 -0
- package/dist/workspace/ci-builds.d.ts.map +1 -1
- package/dist/workspace/ci-builds.js +14 -0
- package/dist/workspace/ci-green.d.ts +45 -2
- package/dist/workspace/ci-green.d.ts.map +1 -1
- package/dist/workspace/ci-green.js +123 -5
- package/dist/workspace/ci-quarantine-report.d.ts +80 -0
- package/dist/workspace/ci-quarantine-report.d.ts.map +1 -0
- package/dist/workspace/ci-quarantine-report.js +204 -0
- package/dist/workspace/ci-quarantine.d.ts +73 -0
- package/dist/workspace/ci-quarantine.d.ts.map +1 -0
- package/dist/workspace/ci-quarantine.js +170 -0
- package/dist/workspace/ci-serve.d.ts.map +1 -1
- package/dist/workspace/ci-serve.js +7 -4
- package/dist/workspace/class-data.d.ts +3 -1
- package/dist/workspace/class-data.d.ts.map +1 -1
- package/dist/workspace/class-data.js +4 -1
- package/dist/workspace/declaration.d.ts +45 -2
- package/dist/workspace/declaration.d.ts.map +1 -1
- package/dist/workspace/declaration.js +45 -2
- package/dist/workspace/declaration.schema.json +51 -3
- package/dist/workspace/forge-work.d.ts +76 -0
- package/dist/workspace/forge-work.d.ts.map +1 -0
- package/dist/workspace/forge-work.js +160 -0
- package/dist/workspace/identity-gate-rule.d.ts +3 -2
- package/dist/workspace/identity-gate-rule.d.ts.map +1 -1
- package/dist/workspace/identity-gate-rule.js +5 -7
- package/dist/workspace/identity.d.ts +3 -2
- package/dist/workspace/identity.d.ts.map +1 -1
- package/dist/workspace/identity.js +6 -3
- package/dist/workspace/intent-cli.d.ts +3 -2
- package/dist/workspace/intent-cli.d.ts.map +1 -1
- package/dist/workspace/intent-cli.js +26 -5
- package/dist/workspace/intent-record.d.ts +3 -0
- package/dist/workspace/intent-record.d.ts.map +1 -1
- package/dist/workspace/intent-record.schema.json +32 -0
- package/dist/workspace/intent.d.ts +9 -0
- package/dist/workspace/intent.d.ts.map +1 -1
- package/dist/workspace/intent.js +2 -0
- package/dist/workspace/intent.schema.json +32 -0
- package/dist/workspace/kind-readers.d.ts.map +1 -1
- package/dist/workspace/kind-readers.js +2 -1
- package/dist/workspace/kinds.d.ts +6 -1
- package/dist/workspace/kinds.d.ts.map +1 -1
- package/dist/workspace/kinds.js +8 -3
- package/dist/workspace/plan-stale.schema.json +286 -0
- package/dist/workspace/release-candidates.d.ts +42 -7
- package/dist/workspace/release-candidates.d.ts.map +1 -1
- package/dist/workspace/release-candidates.js +64 -23
- package/dist/workspace/release-candidates.schema.json +55 -2
- package/dist/workspace/releases.schema.json +47 -0
- package/dist/workspace/trust/policy.d.ts +10 -0
- package/dist/workspace/trust/policy.d.ts.map +1 -1
- package/dist/workspace/trust/policy.js +19 -1
- package/dist/workspace/trust/run-commits.d.ts.map +1 -1
- package/dist/workspace/trust/run-commits.js +2 -1
- package/dist/workspace/trust/seal.d.ts.map +1 -1
- package/dist/workspace/trust/seal.js +34 -3
- package/dist/workspace/trust/trust-files.d.ts.map +1 -1
- package/dist/workspace/trust/trust-files.js +6 -1
- package/package.json +2 -1
- package/src/cli/handlers/approve-external-signature.test.ts +328 -0
- package/src/cli/handlers/approve.ts +206 -18
- package/src/cli/handlers/plan.ts +74 -0
- package/src/cli/handlers/pr.ts +2 -1
- package/src/cli/handlers/release.ts +84 -20
- package/src/cli/main.ts +48 -7
- package/src/cli/mcp/workspace-tools.ts +2 -1
- package/src/cli/parse-args.ts +33 -0
- package/src/cli/registry.ts +18 -2
- package/src/config.ts +8 -0
- package/src/gate-decision-bundle.test.ts +4 -2
- package/src/gate-decision.ts +11 -2
- package/src/gate-statement.schema.json +46 -0
- package/src/lifecycle/__fixtures__/publish-fakes.ts +125 -5
- package/src/lifecycle/gate-ledger.ts +34 -5
- package/src/lifecycle/gate-seal.ts +86 -15
- package/src/lifecycle/gate-statement.ts +144 -0
- package/src/lifecycle/gate-webauthn.test.ts +77 -0
- package/src/lifecycle/gate-webauthn.ts +133 -0
- package/src/lifecycle/git.ts +23 -19
- package/src/lifecycle/ledger-remote.test.ts +183 -0
- package/src/lifecycle/ledger-remote.ts +46 -0
- package/src/lifecycle/plan-stale.test.ts +149 -0
- package/src/lifecycle/plan-stale.ts +172 -0
- package/src/lifecycle/publish-credentials.ts +2 -0
- package/src/lifecycle/publish-declaration.ts +116 -1
- package/src/lifecycle/publish-forge.ts +14 -4
- package/src/lifecycle/publish-git-ssh.ts +202 -0
- package/src/lifecycle/publish-github.ts +174 -0
- package/src/lifecycle/publish-homebrew.test.ts +358 -0
- package/src/lifecycle/publish-homebrew.ts +283 -0
- package/src/lifecycle/publish-marketplace.test.ts +406 -0
- package/src/lifecycle/publish-marketplace.ts +421 -0
- package/src/lifecycle/publish-resume.test.ts +40 -0
- package/src/lifecycle/publish-target-context.test.ts +2 -2
- package/src/lifecycle/publish-targets.test.ts +23 -0
- package/src/lifecycle/publish-targets.ts +15 -0
- package/src/lifecycle/publish-tauri.test.ts +163 -0
- package/src/lifecycle/publish-tauri.ts +198 -0
- package/src/lifecycle/release-cut-lane.test.ts +177 -0
- package/src/lifecycle/release-cut-override.test.ts +213 -0
- package/src/lifecycle/release-cut.ts +198 -17
- package/src/lifecycle/release-publish.ts +23 -3
- package/src/lifecycle/release-revocation.ts +5 -4
- package/src/lifecycle/release-store.ts +44 -0
- package/src/lifecycle/snapshot-store.ts +16 -9
- package/src/lifecycle/test-passkey.ts +55 -0
- package/src/notify-bundle.test.ts +3 -1
- package/src/notify.schema.json +12 -3
- package/src/notify.ts +20 -3
- package/src/op/gate.ts +2 -1
- package/src/override-gate-bundle.test.ts +2 -0
- package/src/pr-forge-bundle.test.ts +2 -2
- package/src/pr-forge.test.ts +38 -0
- package/src/pr-forge.ts +93 -11
- package/src/pr-requires.test.ts +9 -0
- package/src/release-floors.ts +1 -1
- package/src/stage-hooks-bundle.test.ts +2 -0
- package/src/wave-runtime-bundle.test.ts +3 -2
- package/src/workspace/ci-builds.ts +27 -0
- package/src/workspace/ci-green-stale.test.ts +193 -0
- package/src/workspace/ci-green.ts +137 -6
- package/src/workspace/ci-quarantine-report.test.ts +145 -0
- package/src/workspace/ci-quarantine-report.ts +234 -0
- package/src/workspace/ci-quarantine.test.ts +160 -0
- package/src/workspace/ci-quarantine.ts +188 -0
- package/src/workspace/ci-serve.ts +7 -4
- package/src/workspace/class-data.ts +5 -1
- package/src/workspace/declaration.schema.json +51 -3
- package/src/workspace/declaration.test.ts +1 -0
- package/src/workspace/declaration.ts +88 -5
- package/src/workspace/forge-work.test.ts +143 -0
- package/src/workspace/forge-work.ts +195 -0
- package/src/workspace/identity-gate-rule.ts +6 -8
- package/src/workspace/identity.ts +6 -3
- package/src/workspace/intent-cli.ts +24 -5
- package/src/workspace/intent-record.schema.json +32 -0
- package/src/workspace/intent-record.ts +3 -0
- package/src/workspace/intent.schema.json +32 -0
- package/src/workspace/intent.ts +9 -0
- package/src/workspace/kind-readers.ts +2 -1
- package/src/workspace/kinds.test.ts +13 -0
- package/src/workspace/kinds.ts +12 -3
- package/src/workspace/plan-stale.schema.json +286 -0
- package/src/workspace/release-candidates.schema.json +55 -2
- package/src/workspace/release-candidates.test.ts +77 -4
- package/src/workspace/release-candidates.ts +80 -23
- package/src/workspace/releases.schema.json +47 -0
- package/src/workspace/trust/gate-seal.test.ts +44 -0
- package/src/workspace/trust/policy.ts +24 -1
- package/src/workspace/trust/run-commits.ts +2 -1
- package/src/workspace/trust/seal.ts +35 -3
- package/src/workspace/trust/trust-files.test.ts +5 -0
- package/src/workspace/trust/trust-files.ts +15 -1
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The editor marketplace target (#4676): a packaged `.vsix` published to the
|
|
3
|
+
* VS Code Marketplace or to Open VSX.
|
|
4
|
+
*
|
|
5
|
+
* The extension's publisher, name and version are read from the
|
|
6
|
+
* `extension/package.json` inside the `.vsix`, and the file must match the
|
|
7
|
+
* digest the release records for it.
|
|
8
|
+
*
|
|
9
|
+
* A marketplace has no draft: a version is visible as soon as it is
|
|
10
|
+
* uploaded, and a version can't be uploaded twice. So the stage uploads
|
|
11
|
+
* nothing. It checks what it can without changing anything: the file and its
|
|
12
|
+
* digest, the token, and whether the marketplace already has the version.
|
|
13
|
+
* The reveal uploads. A failure of another target's stage therefore leaves
|
|
14
|
+
* nothing on a marketplace, and a marketplace's own failure shows only at the
|
|
15
|
+
* reveal, after the targets before it revealed.
|
|
16
|
+
*
|
|
17
|
+
* - Open VSX, through its REST API: the stage reads
|
|
18
|
+
* `GET {registry}/api/{namespace}` (a missing namespace is refused before
|
|
19
|
+
* anything reveals) and `GET {registry}/api/{namespace}/{name}/{version}`.
|
|
20
|
+
* A version already there is `present` when its download's SHA-256 is the
|
|
21
|
+
* file's, and refused otherwise (`publish-marketplace-version-exists`). The
|
|
22
|
+
* reveal sends the file with `POST {registry}/api/-/publish`, then
|
|
23
|
+
* downloads what Open VSX serves for the version and refuses a digest that
|
|
24
|
+
* differs (`publish-marketplace-digest-mismatch`).
|
|
25
|
+
* - The VS Code Marketplace, through `vsce`: the stage asks the gallery's
|
|
26
|
+
* public `extensionquery` API for the extension's versions, and a version
|
|
27
|
+
* already there is `present`, by version only, since the gallery reports no
|
|
28
|
+
* digest. The reveal runs `vsce publish --packagePath <file>` with the
|
|
29
|
+
* token in `VSCE_PAT`. `vsce` must be on `PATH` (`npm i -g @vscode/vsce`).
|
|
30
|
+
*
|
|
31
|
+
* The token is read from `tokenEnv`, else `VSCE_PAT` or `OVSX_PAT`, the
|
|
32
|
+
* variables `vsce` and `ovsx` read, and is masked in all output.
|
|
33
|
+
*
|
|
34
|
+
* Or the target authenticates with the run's identity, with no stored
|
|
35
|
+
* token (#4698):
|
|
36
|
+
*
|
|
37
|
+
* - `auth: "azure-credential"` (VS Code Marketplace): `vsce` runs with
|
|
38
|
+
* `--azure-credential`, which gets a Microsoft Entra token from the job's
|
|
39
|
+
* Azure sign-in, such as the one `azure/login` makes from the run's OIDC
|
|
40
|
+
* token. `VSCE_PAT` is taken out of vsce's environment, since vsce prefers
|
|
41
|
+
* a PAT it finds there. The stage runs
|
|
42
|
+
* `vsce verify-pat --azure-credential <publisher>`, which signs in and asks
|
|
43
|
+
* the marketplace for the identity's role on the publisher, and changes
|
|
44
|
+
* nothing.
|
|
45
|
+
* - `auth: "trusted-publishing"` (Open VSX): the run's OIDC ID token, from
|
|
46
|
+
* GitHub Actions (a job with `id-token: write`) or from `OVSX_ID_TOKEN`, is
|
|
47
|
+
* exchanged at `POST {registry}/api/-/trusted-publishing/token` for a
|
|
48
|
+
* publishing token that lasts minutes, as `ovsx publish --trusted-publishing`
|
|
49
|
+
* does. The stage makes the exchange to check that Open VSX takes this
|
|
50
|
+
* workflow as a trusted publisher of the extension, and drops the token;
|
|
51
|
+
* the reveal exchanges again for the upload.
|
|
52
|
+
*
|
|
53
|
+
* With `onRefusal: "warn"`, a marketplace that refuses the reveal's upload,
|
|
54
|
+
* or a request around it, is a warning: the reveal returns the target with
|
|
55
|
+
* its items `refused` and a `warning`, and the publish goes on. Every check
|
|
56
|
+
* the stage makes still refuses, and so does a digest that differs after an
|
|
57
|
+
* upload.
|
|
58
|
+
*/
|
|
59
|
+
import type { MarketplacePublishDeclaration } from "./publish-declaration.js";
|
|
60
|
+
import { type PublishDeps, type PublishTarget } from "./release-publish.js";
|
|
61
|
+
/** The first chant that publishes a `marketplace` target (#4676). */
|
|
62
|
+
export declare const PUBLISH_MARKETPLACE_FLOOR = "0.124.63";
|
|
63
|
+
/** The first chant that reads a marketplace target's `auth` (#4698). */
|
|
64
|
+
export declare const PUBLISH_MARKETPLACE_AUTH_FLOOR = "0.124.64";
|
|
65
|
+
/** The first chant that reads a marketplace target's `onRefusal` (#4698). */
|
|
66
|
+
export declare const PUBLISH_MARKETPLACE_ON_REFUSAL_FLOOR = "0.124.64";
|
|
67
|
+
export declare const OPEN_VSX_REGISTRY = "https://open-vsx.org";
|
|
68
|
+
export declare const VSCODE_GALLERY = "https://marketplace.visualstudio.com";
|
|
69
|
+
/** The variable an OIDC ID token for Open VSX is read from outside GitHub Actions, as `ovsx` reads it. */
|
|
70
|
+
export declare const OVSX_ID_TOKEN_ENV = "OVSX_ID_TOKEN";
|
|
71
|
+
export type MarketplaceAuth = NonNullable<MarketplacePublishDeclaration["auth"]>;
|
|
72
|
+
/** The declaration's `auth`, refused when the marketplace does not take it or when `tokenEnv` is set with another. */
|
|
73
|
+
export declare function marketplaceAuth(decl: Pick<MarketplacePublishDeclaration, "marketplace" | "auth" | "tokenEnv">): MarketplaceAuth;
|
|
74
|
+
/** The variables a marketplace's credential is read from, whose values are masked. */
|
|
75
|
+
export declare function marketplaceTokenEnv(decl: Pick<MarketplacePublishDeclaration, "marketplace" | "tokenEnv" | "auth">): string[];
|
|
76
|
+
/** One file of a zip archive, or null when it holds none by that name. Reads stored and deflated entries; refuses a zip64 archive. */
|
|
77
|
+
export declare function readZipEntry(zip: Buffer, name: string): Buffer | null;
|
|
78
|
+
/** The publisher, name and version a `.vsix` declares. */
|
|
79
|
+
export declare function vsixIdentity(bytes: Buffer, path: string): {
|
|
80
|
+
publisher: string;
|
|
81
|
+
name: string;
|
|
82
|
+
version: string;
|
|
83
|
+
};
|
|
84
|
+
export declare function marketplaceTarget(decl: MarketplacePublishDeclaration, deps: PublishDeps): PublishTarget;
|
|
85
|
+
//# sourceMappingURL=publish-marketplace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish-marketplace.d.ts","sourceRoot":"","sources":["../../src/lifecycle/publish-marketplace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AAMH,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAC;AAE3E,OAAO,EAGL,KAAK,WAAW,EAIhB,KAAK,aAAa,EAEnB,MAAM,mBAAmB,CAAC;AAG3B,qEAAqE;AACrE,eAAO,MAAM,yBAAyB,aAAa,CAAC;AAEpD,wEAAwE;AACxE,eAAO,MAAM,8BAA8B,aAAe,CAAC;AAE3D,6EAA6E;AAC7E,eAAO,MAAM,oCAAoC,aAAe,CAAC;AAEjE,eAAO,MAAM,iBAAiB,yBAAyB,CAAC;AACxD,eAAO,MAAM,cAAc,yCAAyC,CAAC;AAErE,0GAA0G;AAC1G,eAAO,MAAM,iBAAiB,kBAAkB,CAAC;AAEjD,MAAM,MAAM,eAAe,GAAG,WAAW,CAAC,6BAA6B,CAAC,MAAM,CAAC,CAAC,CAAC;AAEjF,sHAAsH;AACtH,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,6BAA6B,EAAE,aAAa,GAAG,MAAM,GAAG,UAAU,CAAC,GAAG,eAAe,CAY/H;AAED,sFAAsF;AACtF,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,IAAI,CAAC,6BAA6B,EAAE,aAAa,GAAG,UAAU,GAAG,MAAM,CAAC,GAAG,MAAM,EAAE,CAM5H;AAKD,sIAAsI;AACtI,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA6BrE;AAED,0DAA0D;AAC1D,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAc9G;AAkBD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,6BAA6B,EAAE,IAAI,EAAE,WAAW,GAAG,aAAa,CA0OvG"}
|
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The editor marketplace target (#4676): a packaged `.vsix` published to the
|
|
3
|
+
* VS Code Marketplace or to Open VSX.
|
|
4
|
+
*
|
|
5
|
+
* The extension's publisher, name and version are read from the
|
|
6
|
+
* `extension/package.json` inside the `.vsix`, and the file must match the
|
|
7
|
+
* digest the release records for it.
|
|
8
|
+
*
|
|
9
|
+
* A marketplace has no draft: a version is visible as soon as it is
|
|
10
|
+
* uploaded, and a version can't be uploaded twice. So the stage uploads
|
|
11
|
+
* nothing. It checks what it can without changing anything: the file and its
|
|
12
|
+
* digest, the token, and whether the marketplace already has the version.
|
|
13
|
+
* The reveal uploads. A failure of another target's stage therefore leaves
|
|
14
|
+
* nothing on a marketplace, and a marketplace's own failure shows only at the
|
|
15
|
+
* reveal, after the targets before it revealed.
|
|
16
|
+
*
|
|
17
|
+
* - Open VSX, through its REST API: the stage reads
|
|
18
|
+
* `GET {registry}/api/{namespace}` (a missing namespace is refused before
|
|
19
|
+
* anything reveals) and `GET {registry}/api/{namespace}/{name}/{version}`.
|
|
20
|
+
* A version already there is `present` when its download's SHA-256 is the
|
|
21
|
+
* file's, and refused otherwise (`publish-marketplace-version-exists`). The
|
|
22
|
+
* reveal sends the file with `POST {registry}/api/-/publish`, then
|
|
23
|
+
* downloads what Open VSX serves for the version and refuses a digest that
|
|
24
|
+
* differs (`publish-marketplace-digest-mismatch`).
|
|
25
|
+
* - The VS Code Marketplace, through `vsce`: the stage asks the gallery's
|
|
26
|
+
* public `extensionquery` API for the extension's versions, and a version
|
|
27
|
+
* already there is `present`, by version only, since the gallery reports no
|
|
28
|
+
* digest. The reveal runs `vsce publish --packagePath <file>` with the
|
|
29
|
+
* token in `VSCE_PAT`. `vsce` must be on `PATH` (`npm i -g @vscode/vsce`).
|
|
30
|
+
*
|
|
31
|
+
* The token is read from `tokenEnv`, else `VSCE_PAT` or `OVSX_PAT`, the
|
|
32
|
+
* variables `vsce` and `ovsx` read, and is masked in all output.
|
|
33
|
+
*
|
|
34
|
+
* Or the target authenticates with the run's identity, with no stored
|
|
35
|
+
* token (#4698):
|
|
36
|
+
*
|
|
37
|
+
* - `auth: "azure-credential"` (VS Code Marketplace): `vsce` runs with
|
|
38
|
+
* `--azure-credential`, which gets a Microsoft Entra token from the job's
|
|
39
|
+
* Azure sign-in, such as the one `azure/login` makes from the run's OIDC
|
|
40
|
+
* token. `VSCE_PAT` is taken out of vsce's environment, since vsce prefers
|
|
41
|
+
* a PAT it finds there. The stage runs
|
|
42
|
+
* `vsce verify-pat --azure-credential <publisher>`, which signs in and asks
|
|
43
|
+
* the marketplace for the identity's role on the publisher, and changes
|
|
44
|
+
* nothing.
|
|
45
|
+
* - `auth: "trusted-publishing"` (Open VSX): the run's OIDC ID token, from
|
|
46
|
+
* GitHub Actions (a job with `id-token: write`) or from `OVSX_ID_TOKEN`, is
|
|
47
|
+
* exchanged at `POST {registry}/api/-/trusted-publishing/token` for a
|
|
48
|
+
* publishing token that lasts minutes, as `ovsx publish --trusted-publishing`
|
|
49
|
+
* does. The stage makes the exchange to check that Open VSX takes this
|
|
50
|
+
* workflow as a trusted publisher of the extension, and drops the token;
|
|
51
|
+
* the reveal exchanges again for the upload.
|
|
52
|
+
*
|
|
53
|
+
* With `onRefusal: "warn"`, a marketplace that refuses the reveal's upload,
|
|
54
|
+
* or a request around it, is a warning: the reveal returns the target with
|
|
55
|
+
* its items `refused` and a `warning`, and the publish goes on. Every check
|
|
56
|
+
* the stage makes still refuses, and so does a digest that differs after an
|
|
57
|
+
* upload.
|
|
58
|
+
*/
|
|
59
|
+
import { spawn } from "node:child_process";
|
|
60
|
+
import { readFileSync } from "node:fs";
|
|
61
|
+
import { inflateRawSync } from "node:zlib";
|
|
62
|
+
import { readCredential } from "./publish-credentials.js";
|
|
63
|
+
import { bytesDigest, checkReleaseDigest, memberFile, publishTargetKey } from "./publish-targets.js";
|
|
64
|
+
import { PublishTargetError, } from "./release-publish.js";
|
|
65
|
+
import { NEXT_RELEASE } from "../release-floors.js";
|
|
66
|
+
/** The first chant that publishes a `marketplace` target (#4676). */
|
|
67
|
+
export const PUBLISH_MARKETPLACE_FLOOR = "0.124.63";
|
|
68
|
+
/** The first chant that reads a marketplace target's `auth` (#4698). */
|
|
69
|
+
export const PUBLISH_MARKETPLACE_AUTH_FLOOR = NEXT_RELEASE;
|
|
70
|
+
/** The first chant that reads a marketplace target's `onRefusal` (#4698). */
|
|
71
|
+
export const PUBLISH_MARKETPLACE_ON_REFUSAL_FLOOR = NEXT_RELEASE;
|
|
72
|
+
export const OPEN_VSX_REGISTRY = "https://open-vsx.org";
|
|
73
|
+
export const VSCODE_GALLERY = "https://marketplace.visualstudio.com";
|
|
74
|
+
/** The variable an OIDC ID token for Open VSX is read from outside GitHub Actions, as `ovsx` reads it. */
|
|
75
|
+
export const OVSX_ID_TOKEN_ENV = "OVSX_ID_TOKEN";
|
|
76
|
+
/** The declaration's `auth`, refused when the marketplace does not take it or when `tokenEnv` is set with another. */
|
|
77
|
+
export function marketplaceAuth(decl) {
|
|
78
|
+
const auth = decl.auth ?? "token";
|
|
79
|
+
const wrong = auth === "azure-credential" && decl.marketplace !== "vscode"
|
|
80
|
+
? "auth: azure-credential is the VS Code Marketplace's; Open VSX takes token or trusted-publishing"
|
|
81
|
+
: auth === "trusted-publishing" && decl.marketplace !== "openvsx"
|
|
82
|
+
? "auth: trusted-publishing is Open VSX's; the VS Code Marketplace takes token or azure-credential"
|
|
83
|
+
: auth !== "token" && decl.tokenEnv !== undefined
|
|
84
|
+
? `tokenEnv names a token, and auth: ${auth} reads none`
|
|
85
|
+
: null;
|
|
86
|
+
if (wrong)
|
|
87
|
+
throw new PublishTargetError("publish-marketplace-auth-invalid", `a marketplace target for ${decl.marketplace}: ${wrong}`, "Fix the target in release.publish in chant.config.ts.");
|
|
88
|
+
return auth;
|
|
89
|
+
}
|
|
90
|
+
/** The variables a marketplace's credential is read from, whose values are masked. */
|
|
91
|
+
export function marketplaceTokenEnv(decl) {
|
|
92
|
+
const auth = decl.auth ?? "token";
|
|
93
|
+
// vsce's Entra sign-in reads a client secret from AZURE_CLIENT_SECRET when one is set; chant reads none.
|
|
94
|
+
if (auth === "azure-credential")
|
|
95
|
+
return ["AZURE_CLIENT_SECRET"];
|
|
96
|
+
if (auth === "trusted-publishing")
|
|
97
|
+
return [OVSX_ID_TOKEN_ENV];
|
|
98
|
+
return [decl.tokenEnv ?? (decl.marketplace === "vscode" ? "VSCE_PAT" : "OVSX_PAT")];
|
|
99
|
+
}
|
|
100
|
+
/** The codes a reveal turns into a warning under `onRefusal: "warn"`: the marketplace refused or failed a request. */
|
|
101
|
+
const REFUSALS = new Set(["publish-marketplace-failed", "publish-marketplace-trusted-publishing"]);
|
|
102
|
+
/** One file of a zip archive, or null when it holds none by that name. Reads stored and deflated entries; refuses a zip64 archive. */
|
|
103
|
+
export function readZipEntry(zip, name) {
|
|
104
|
+
let end = -1;
|
|
105
|
+
for (let i = zip.length - 22; i >= Math.max(0, zip.length - 22 - 0xffff); i--) {
|
|
106
|
+
if (zip.readUInt32LE(i) === 0x06054b50) {
|
|
107
|
+
end = i;
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (end < 0)
|
|
112
|
+
throw new Error("not a zip archive: no end of central directory");
|
|
113
|
+
const count = zip.readUInt16LE(end + 10);
|
|
114
|
+
let at = zip.readUInt32LE(end + 16);
|
|
115
|
+
if (count === 0xffff || at === 0xffffffff)
|
|
116
|
+
throw new Error("a zip64 archive, which chant does not read");
|
|
117
|
+
for (let i = 0; i < count; i++) {
|
|
118
|
+
if (zip.readUInt32LE(at) !== 0x02014b50)
|
|
119
|
+
throw new Error("a malformed zip central directory");
|
|
120
|
+
const method = zip.readUInt16LE(at + 10);
|
|
121
|
+
const size = zip.readUInt32LE(at + 20);
|
|
122
|
+
const nameLen = zip.readUInt16LE(at + 28);
|
|
123
|
+
const skip = nameLen + zip.readUInt16LE(at + 30) + zip.readUInt16LE(at + 32);
|
|
124
|
+
const local = zip.readUInt32LE(at + 42);
|
|
125
|
+
if (zip.toString("utf-8", at + 46, at + 46 + nameLen) === name) {
|
|
126
|
+
const data = local + 30 + zip.readUInt16LE(local + 26) + zip.readUInt16LE(local + 28);
|
|
127
|
+
const raw = zip.subarray(data, data + size);
|
|
128
|
+
if (method === 0)
|
|
129
|
+
return Buffer.from(raw);
|
|
130
|
+
if (method === 8)
|
|
131
|
+
return inflateRawSync(raw);
|
|
132
|
+
throw new Error(`${name} is compressed with method ${method}, which chant does not read`);
|
|
133
|
+
}
|
|
134
|
+
at += 46 + skip;
|
|
135
|
+
}
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
/** The publisher, name and version a `.vsix` declares. */
|
|
139
|
+
export function vsixIdentity(bytes, path) {
|
|
140
|
+
let manifest;
|
|
141
|
+
try {
|
|
142
|
+
const entry = readZipEntry(bytes, "extension/package.json");
|
|
143
|
+
if (!entry)
|
|
144
|
+
throw new Error("it holds no extension/package.json");
|
|
145
|
+
manifest = JSON.parse(entry.toString("utf-8"));
|
|
146
|
+
}
|
|
147
|
+
catch (err) {
|
|
148
|
+
throw new PublishTargetError("publish-marketplace-vsix-invalid", `${path} is not a .vsix chant can read: ${err instanceof Error ? err.message : String(err)}`, "Package it with vsce package.");
|
|
149
|
+
}
|
|
150
|
+
const { publisher, name, version } = manifest;
|
|
151
|
+
if (typeof publisher !== "string" || typeof name !== "string" || typeof version !== "string" || !publisher || !name || !version) {
|
|
152
|
+
throw new PublishTargetError("publish-marketplace-vsix-invalid", `${path}'s extension/package.json needs publisher, name and version`);
|
|
153
|
+
}
|
|
154
|
+
return { publisher, name, version };
|
|
155
|
+
}
|
|
156
|
+
function run(bin, args, ctx, env) {
|
|
157
|
+
return new Promise((resolvePromise, reject) => {
|
|
158
|
+
const child = spawn(bin, args, { cwd: ctx.cwd, env, stdio: ["ignore", "pipe", "pipe"] });
|
|
159
|
+
const chunks = [];
|
|
160
|
+
child.stdout.on("data", (c) => chunks.push(c.toString("utf-8")));
|
|
161
|
+
child.stderr.on("data", (c) => chunks.push(c.toString("utf-8")));
|
|
162
|
+
child.on("error", reject);
|
|
163
|
+
child.on("close", (code) => resolvePromise({
|
|
164
|
+
code: code ?? 1,
|
|
165
|
+
output: chunks.join("").split("\n").filter((l) => l.trim() !== "").map((l) => ctx.redactor.redact(l)),
|
|
166
|
+
}));
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
export function marketplaceTarget(decl, deps) {
|
|
170
|
+
const fetchImpl = deps.fetch ?? ((url, init) => fetch(url, init));
|
|
171
|
+
const auth = marketplaceAuth(decl);
|
|
172
|
+
const tokenNames = marketplaceTokenEnv(decl);
|
|
173
|
+
const label = decl.marketplace === "vscode" ? "VS Code Marketplace" : "Open VSX";
|
|
174
|
+
const registry = (decl.registry ?? (decl.marketplace === "vscode" ? VSCODE_GALLERY : OPEN_VSX_REGISTRY)).replace(/\/+$/, "");
|
|
175
|
+
const setup = (ctx) => {
|
|
176
|
+
const abs = memberFile(ctx.cwd, decl.vsix);
|
|
177
|
+
const bytes = readFileSync(abs);
|
|
178
|
+
const digest = bytesDigest(new Uint8Array(bytes));
|
|
179
|
+
checkReleaseDigest(ctx.release, "asset", ctx.cwd, decl.vsix, [digest]);
|
|
180
|
+
const id = vsixIdentity(bytes, decl.vsix);
|
|
181
|
+
let token = null;
|
|
182
|
+
if (auth === "token") {
|
|
183
|
+
token = readCredential(ctx.env, tokenNames, ctx.redactor);
|
|
184
|
+
if (!token) {
|
|
185
|
+
throw new PublishTargetError("publish-credentials-missing", `the ${label} target reads its token from ${tokenNames[0]}, and it is not set`, `Set ${tokenNames[0]} in the job's or the shell's environment.`);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
if (auth === "trusted-publishing" && !ctx.env[OVSX_ID_TOKEN_ENV] && !(ctx.env.ACTIONS_ID_TOKEN_REQUEST_URL && ctx.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN)) {
|
|
189
|
+
throw new PublishTargetError("publish-credentials-missing", `the Open VSX target publishes with trusted publishing, and this run has no OIDC ID token: not a GitHub Actions job with id-token: write, and ${OVSX_ID_TOKEN_ENV} is not set`, `In GitHub Actions, give the job permissions: id-token: write. Elsewhere, put an ID token whose audience is ${registry} in ${OVSX_ID_TOKEN_ENV}.`);
|
|
190
|
+
}
|
|
191
|
+
const destination = decl.marketplace === "vscode" ? `${registry}/items?itemName=${id.publisher}.${id.name}` : `${registry}/extension/${id.publisher}/${id.name}/${id.version}`;
|
|
192
|
+
const item = { name: `${id.publisher}.${id.name}@${id.version}`, destination, digest };
|
|
193
|
+
return { abs, bytes, digest, id, token, item };
|
|
194
|
+
};
|
|
195
|
+
const get = async (url, init = { method: "GET", headers: {} }) => {
|
|
196
|
+
const res = await fetchImpl(url, { ...init, headers: { "user-agent": "chant", ...init.headers } });
|
|
197
|
+
return { status: res.status, text: await res.text().catch(() => "") };
|
|
198
|
+
};
|
|
199
|
+
function fail(ctx, what, status, text) {
|
|
200
|
+
throw new PublishTargetError("publish-marketplace-failed", ctx.redactor.redact(`${what} on ${label} answered ${status}${text ? `: ${text.slice(0, 300)}` : ""}`));
|
|
201
|
+
}
|
|
202
|
+
/** Open VSX: the SHA-256 of what it serves for the version, or null when it has no such version. */
|
|
203
|
+
const openVsxServed = async (ctx, id) => {
|
|
204
|
+
const meta = await get(`${registry}/api/${encodeURIComponent(id.publisher)}/${encodeURIComponent(id.name)}/${encodeURIComponent(id.version)}`);
|
|
205
|
+
if (meta.status === 404)
|
|
206
|
+
return null;
|
|
207
|
+
if (meta.status !== 200)
|
|
208
|
+
fail(ctx, `reading ${id.publisher}.${id.name}@${id.version}`, meta.status, meta.text);
|
|
209
|
+
const download = JSON.parse(meta.text).files?.download;
|
|
210
|
+
if (typeof download !== "string")
|
|
211
|
+
fail(ctx, `reading the download of ${id.publisher}.${id.name}@${id.version}`, meta.status, "no files.download");
|
|
212
|
+
const res = await fetchImpl(download, { method: "GET", headers: { "user-agent": "chant" } });
|
|
213
|
+
if (res.status !== 200)
|
|
214
|
+
fail(ctx, `downloading ${id.publisher}.${id.name}@${id.version}`, res.status, "");
|
|
215
|
+
if (!res.arrayBuffer)
|
|
216
|
+
throw new PublishTargetError("publish-marketplace-failed", "the fetch this publish runs with can't read a response's bytes, so the download's digest can't be checked");
|
|
217
|
+
return bytesDigest(new Uint8Array(await res.arrayBuffer()));
|
|
218
|
+
};
|
|
219
|
+
/** The run's OIDC ID token for Open VSX: `OVSX_ID_TOKEN`, else one GitHub Actions issues with the registry as its audience. */
|
|
220
|
+
const idToken = async (ctx) => {
|
|
221
|
+
const direct = readCredential(ctx.env, [OVSX_ID_TOKEN_ENV], ctx.redactor);
|
|
222
|
+
if (direct)
|
|
223
|
+
return direct.value;
|
|
224
|
+
const url = new URL(ctx.env.ACTIONS_ID_TOKEN_REQUEST_URL ?? "");
|
|
225
|
+
url.searchParams.set("audience", registry);
|
|
226
|
+
const res = await fetchImpl(url.toString(), { method: "GET", headers: { authorization: `Bearer ${ctx.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN ?? ""}`, accept: "application/json" } });
|
|
227
|
+
const text = await res.text().catch(() => "");
|
|
228
|
+
const value = res.status === 200 ? JSON.parse(text).value : undefined;
|
|
229
|
+
if (typeof value !== "string" || !value) {
|
|
230
|
+
throw new PublishTargetError("publish-marketplace-trusted-publishing", ctx.redactor.redact(`GitHub Actions gave no OIDC ID token for ${registry}: it answered ${res.status}`), "Give the job permissions: id-token: write.");
|
|
231
|
+
}
|
|
232
|
+
ctx.redactor.add(value);
|
|
233
|
+
return value;
|
|
234
|
+
};
|
|
235
|
+
/** Open VSX trusted publishing: a publishing token for the extension, exchanged for the run's ID token. It lasts minutes. */
|
|
236
|
+
const trustedToken = async (ctx, id) => {
|
|
237
|
+
const token = await idToken(ctx);
|
|
238
|
+
const res = await get(`${registry}/api/-/trusted-publishing/token`, {
|
|
239
|
+
method: "POST",
|
|
240
|
+
headers: { "content-type": "application/json" },
|
|
241
|
+
body: JSON.stringify({ namespace: id.publisher, extension: id.name, token }),
|
|
242
|
+
});
|
|
243
|
+
let body = {};
|
|
244
|
+
try {
|
|
245
|
+
body = JSON.parse(res.text);
|
|
246
|
+
}
|
|
247
|
+
catch {
|
|
248
|
+
// An answer that is not JSON is reported by its status.
|
|
249
|
+
}
|
|
250
|
+
if (res.status < 200 || res.status > 299 || typeof body.value !== "string" || !body.value) {
|
|
251
|
+
const why = typeof body.error === "string" ? body.error : `it answered ${res.status}${res.text ? `: ${res.text.slice(0, 300)}` : ""}`;
|
|
252
|
+
throw new PublishTargetError("publish-marketplace-trusted-publishing", ctx.redactor.redact(`Open VSX at ${registry} gave no trusted-publishing token for ${id.publisher}.${id.name}: ${why}`), `Register this workflow as a trusted publisher of ${id.publisher}.${id.name} at ${registry}/user-settings/trusted-publishers.`);
|
|
253
|
+
}
|
|
254
|
+
ctx.redactor.add(body.value);
|
|
255
|
+
return body.value;
|
|
256
|
+
};
|
|
257
|
+
/** Runs vsce with the target's credential: `VSCE_PAT` for a token, `--azure-credential` and no `VSCE_PAT` for an Entra identity. */
|
|
258
|
+
const vsce = async (ctx, args, token) => {
|
|
259
|
+
const env = { ...ctx.env };
|
|
260
|
+
if (token)
|
|
261
|
+
env.VSCE_PAT = token.value;
|
|
262
|
+
else
|
|
263
|
+
delete env.VSCE_PAT;
|
|
264
|
+
return run(deps.vsce ?? "vsce", token ? args : [...args, "--azure-credential"], ctx, env).catch((err) => {
|
|
265
|
+
throw new PublishTargetError("publish-marketplace-vsce-missing", `vsce could not be run: ${err instanceof Error ? err.message : String(err)}`, "Install it on the job's PATH: npm install -g @vscode/vsce");
|
|
266
|
+
});
|
|
267
|
+
};
|
|
268
|
+
/** The reveal of a target the marketplace refused, under `onRefusal: "warn"`. */
|
|
269
|
+
const refusedResult = (ctx, items, err) => {
|
|
270
|
+
const warning = ctx.redactor.redact(`${label} refused ${items[0]?.name ?? decl.vsix}: ${err.message}. onRefusal is warn, so the publish goes on without it, and the same publish run again tries it again`);
|
|
271
|
+
return { target: target.name, destination: target.destination, items: items.map((i) => ({ ...i, refused: true })), warning };
|
|
272
|
+
};
|
|
273
|
+
/** VS Code Marketplace: whether the gallery lists the version. */
|
|
274
|
+
const galleryHas = async (ctx, id) => {
|
|
275
|
+
const res = await get(`${registry}/_apis/public/gallery/extensionquery`, {
|
|
276
|
+
method: "POST",
|
|
277
|
+
headers: { "content-type": "application/json", accept: "application/json;api-version=3.0-preview.1" },
|
|
278
|
+
body: JSON.stringify({ filters: [{ criteria: [{ filterType: 7, value: `${id.publisher}.${id.name}` }], pageNumber: 1, pageSize: 1 }], flags: 1 }),
|
|
279
|
+
});
|
|
280
|
+
if (res.status !== 200)
|
|
281
|
+
fail(ctx, `asking for ${id.publisher}.${id.name}`, res.status, res.text);
|
|
282
|
+
const body = JSON.parse(res.text);
|
|
283
|
+
return (body.results?.[0]?.extensions?.[0]?.versions ?? []).some((v) => v.version === id.version);
|
|
284
|
+
};
|
|
285
|
+
const target = {
|
|
286
|
+
kind: "marketplace",
|
|
287
|
+
name: `${label} ${decl.vsix}`,
|
|
288
|
+
destination: label,
|
|
289
|
+
credentialEnv: tokenNames,
|
|
290
|
+
key: publishTargetKey(decl),
|
|
291
|
+
async plan(ctx) {
|
|
292
|
+
return [setup(ctx).item];
|
|
293
|
+
},
|
|
294
|
+
async stage(ctx) {
|
|
295
|
+
const { id, digest, token, item } = setup(ctx);
|
|
296
|
+
if (token)
|
|
297
|
+
ctx.log(`using the token from ${token.from}`);
|
|
298
|
+
const done = (present) => ({ target: target.name, destination: target.destination, items: [{ ...item, ...(present ? { present: true } : {}) }], state: present ? { present: "true" } : {} });
|
|
299
|
+
if (decl.marketplace === "openvsx") {
|
|
300
|
+
if (auth === "trusted-publishing") {
|
|
301
|
+
await trustedToken(ctx, id);
|
|
302
|
+
ctx.log(`Open VSX takes this run as a trusted publisher of ${id.publisher}.${id.name}; the reveal asks for a new token, since one lasts minutes`);
|
|
303
|
+
}
|
|
304
|
+
const ns = await get(`${registry}/api/${encodeURIComponent(id.publisher)}`);
|
|
305
|
+
if (ns.status === 404) {
|
|
306
|
+
throw new PublishTargetError("publish-marketplace-no-namespace", `Open VSX at ${registry} has no namespace ${id.publisher}`, `Create it once with: npx ovsx create-namespace ${id.publisher}`);
|
|
307
|
+
}
|
|
308
|
+
if (ns.status !== 200)
|
|
309
|
+
fail(ctx, `reading namespace ${id.publisher}`, ns.status, ns.text);
|
|
310
|
+
const served = await openVsxServed(ctx, id);
|
|
311
|
+
if (served === null) {
|
|
312
|
+
ctx.log(`${item.name} is not on Open VSX yet; it is uploaded at the reveal, since Open VSX has no draft`);
|
|
313
|
+
return done(false);
|
|
314
|
+
}
|
|
315
|
+
if (served !== digest) {
|
|
316
|
+
throw new PublishTargetError("publish-marketplace-version-exists", `Open VSX already has ${item.name}, with digest ${served}, not ${digest}`, "A marketplace version can't be replaced: cut a release with a new version.");
|
|
317
|
+
}
|
|
318
|
+
ctx.log(`${item.name} is already on Open VSX with the same bytes`);
|
|
319
|
+
return done(true);
|
|
320
|
+
}
|
|
321
|
+
if (auth === "azure-credential") {
|
|
322
|
+
ctx.log(`checking the job's Microsoft Entra identity may publish as ${id.publisher}: vsce verify-pat --azure-credential ${id.publisher}`);
|
|
323
|
+
const check = await vsce(ctx, ["verify-pat", id.publisher], null);
|
|
324
|
+
for (const l of check.output)
|
|
325
|
+
ctx.log(`vsce: ${l}`);
|
|
326
|
+
if (check.code !== 0) {
|
|
327
|
+
throw new PublishTargetError("publish-marketplace-azure-credential", `vsce could not sign in with a Microsoft Entra identity that has a role on publisher ${id.publisher}: vsce verify-pat exited ${check.code}${check.output.length ? `: ${check.output.slice(-3).join(" ")}` : ""}`, `Sign in to Azure in the publish's job before it runs, such as with azure/login and the run's OIDC token, as an identity added to the publisher ${id.publisher}.`);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
if (await galleryHas(ctx, id)) {
|
|
331
|
+
ctx.log(`${item.name} is already on the VS Code Marketplace; it reports no digest to compare`);
|
|
332
|
+
return done(true);
|
|
333
|
+
}
|
|
334
|
+
ctx.log(`${item.name} is not on the VS Code Marketplace yet; it is uploaded at the reveal, since the marketplace has no draft`);
|
|
335
|
+
return done(false);
|
|
336
|
+
},
|
|
337
|
+
async reveal(ctx, staged) {
|
|
338
|
+
const items = staged.items.map((i) => ({ name: i.name, destination: i.destination, ...(i.digest ? { digest: i.digest } : {}) }));
|
|
339
|
+
if (staged.state.present === "true")
|
|
340
|
+
return { target: target.name, destination: target.destination, items: items.map((i) => ({ ...i, present: true })) };
|
|
341
|
+
const { abs, bytes, id, digest, token, item } = setup(ctx);
|
|
342
|
+
const refusable = async (step) => {
|
|
343
|
+
try {
|
|
344
|
+
return await step();
|
|
345
|
+
}
|
|
346
|
+
catch (err) {
|
|
347
|
+
if (decl.onRefusal === "warn" && err instanceof PublishTargetError && REFUSALS.has(err.code))
|
|
348
|
+
return refusedResult(ctx, items, err);
|
|
349
|
+
throw err;
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
if (decl.marketplace === "openvsx") {
|
|
353
|
+
// Run again after an upload whose record was lost, the version is there: check it rather than send it twice.
|
|
354
|
+
const uploaded = await refusable(async () => {
|
|
355
|
+
const before = await openVsxServed(ctx, id);
|
|
356
|
+
if (before !== null)
|
|
357
|
+
return before;
|
|
358
|
+
const publishToken = token ? token.value : await trustedToken(ctx, id);
|
|
359
|
+
ctx.log(`uploading ${item.name} (${bytes.byteLength} bytes) to Open VSX${token ? "" : " with a trusted-publishing token"}`);
|
|
360
|
+
const res = await fetchImpl(`${registry}/api/-/publish?token=${encodeURIComponent(publishToken)}`, {
|
|
361
|
+
method: "POST",
|
|
362
|
+
headers: { "user-agent": "chant", "content-type": "application/octet-stream" },
|
|
363
|
+
body: new Uint8Array(bytes),
|
|
364
|
+
});
|
|
365
|
+
if (res.status !== 201 && res.status !== 200)
|
|
366
|
+
fail(ctx, `publishing ${item.name}`, res.status, await res.text().catch(() => ""));
|
|
367
|
+
return null;
|
|
368
|
+
});
|
|
369
|
+
if (uploaded !== null && typeof uploaded === "object")
|
|
370
|
+
return uploaded;
|
|
371
|
+
const before = uploaded;
|
|
372
|
+
const served = before ?? (await openVsxServed(ctx, id));
|
|
373
|
+
if (served !== digest) {
|
|
374
|
+
throw new PublishTargetError("publish-marketplace-digest-mismatch", `Open VSX serves ${item.name} with digest ${served ?? "none"}, and the file published is ${digest}`);
|
|
375
|
+
}
|
|
376
|
+
return { target: target.name, destination: target.destination, items: before === null ? items : items.map((i) => ({ ...i, present: true })) };
|
|
377
|
+
}
|
|
378
|
+
const outcome = await refusable(async () => {
|
|
379
|
+
if (await galleryHas(ctx, id)) {
|
|
380
|
+
ctx.log(`${item.name} is already on the VS Code Marketplace`);
|
|
381
|
+
return true;
|
|
382
|
+
}
|
|
383
|
+
ctx.log(`running vsce publish --packagePath ${decl.vsix}${token ? "" : " --azure-credential"}`);
|
|
384
|
+
const result = await vsce(ctx, ["publish", "--packagePath", abs], token);
|
|
385
|
+
for (const l of result.output)
|
|
386
|
+
ctx.log(`vsce: ${l}`);
|
|
387
|
+
if (result.code !== 0) {
|
|
388
|
+
throw new PublishTargetError("publish-marketplace-failed", `vsce publish of ${item.name} exited ${result.code}${result.output.length ? `: ${result.output.slice(-3).join(" ")}` : ""}`);
|
|
389
|
+
}
|
|
390
|
+
return false;
|
|
391
|
+
});
|
|
392
|
+
if (typeof outcome === "object")
|
|
393
|
+
return outcome;
|
|
394
|
+
return { target: target.name, destination: target.destination, items: outcome ? items.map((i) => ({ ...i, present: true })) : items };
|
|
395
|
+
},
|
|
396
|
+
};
|
|
397
|
+
return target;
|
|
398
|
+
}
|
|
@@ -9,6 +9,12 @@
|
|
|
9
9
|
* as GHCR or Docker Hub over the registry HTTP API, by digest, then tagged.
|
|
10
10
|
* - `forge` (./publish-forge.ts): files attached to the GitHub, GitLab or
|
|
11
11
|
* Forgejo release named by the release's tag.
|
|
12
|
+
* - `homebrew` (./publish-homebrew.ts): a formula in a tap repository on
|
|
13
|
+
* GitHub, rendered from a template with each asset's URL and SHA-256.
|
|
14
|
+
* - `marketplace` (./publish-marketplace.ts): a `.vsix` on the VS Code
|
|
15
|
+
* Marketplace (through `vsce`) or Open VSX (through its REST API).
|
|
16
|
+
* - `tauri-updater` (./publish-tauri.ts): a Tauri updater manifest and the
|
|
17
|
+
* app's bundles on a rolling GitHub release, replaced on each publish.
|
|
12
18
|
*
|
|
13
19
|
* A file a target reads that the release records as an artifact at the same
|
|
14
20
|
* path is checked against the release's digest, and a file that differs is
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish-targets.d.ts","sourceRoot":"","sources":["../../src/lifecycle/publish-targets.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"publish-targets.d.ts","sourceRoot":"","sources":["../../src/lifecycle/publish-targets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAKH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAsB,KAAK,WAAW,EAAE,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC7F,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGhE,6DAA6D;AAC7D,wBAAsB,oBAAoB,CAAC,KAAK,EAAE,SAAS,kBAAkB,EAAE,EAAE,IAAI,GAAE,WAAgB,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAyBjI;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,kBAAkB,GAAG,MAAM,CAEjE;AAED,4EAA4E;AAC5E,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAM5D;AAED,wCAAwC;AACxC,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED,+BAA+B;AAC/B,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAErD;AAED,sCAAsC;AACtC,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAE1C;AAID,uGAAuG;AACvG,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,eAAe,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS,CAGzI;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,eAAe,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAQ/I"}
|
|
@@ -9,6 +9,12 @@
|
|
|
9
9
|
* as GHCR or Docker Hub over the registry HTTP API, by digest, then tagged.
|
|
10
10
|
* - `forge` (./publish-forge.ts): files attached to the GitHub, GitLab or
|
|
11
11
|
* Forgejo release named by the release's tag.
|
|
12
|
+
* - `homebrew` (./publish-homebrew.ts): a formula in a tap repository on
|
|
13
|
+
* GitHub, rendered from a template with each asset's URL and SHA-256.
|
|
14
|
+
* - `marketplace` (./publish-marketplace.ts): a `.vsix` on the VS Code
|
|
15
|
+
* Marketplace (through `vsce`) or Open VSX (through its REST API).
|
|
16
|
+
* - `tauri-updater` (./publish-tauri.ts): a Tauri updater manifest and the
|
|
17
|
+
* app's bundles on a rolling GitHub release, replaced on each publish.
|
|
12
18
|
*
|
|
13
19
|
* A file a target reads that the release records as an artifact at the same
|
|
14
20
|
* path is checked against the release's digest, and a file that differs is
|
|
@@ -34,6 +40,15 @@ export async function createPublishTargets(decls, deps = {}) {
|
|
|
34
40
|
case "forge":
|
|
35
41
|
out.push((await import("./publish-forge.js")).forgeTarget(d, deps));
|
|
36
42
|
break;
|
|
43
|
+
case "homebrew":
|
|
44
|
+
out.push((await import("./publish-homebrew.js")).homebrewTarget(d, deps));
|
|
45
|
+
break;
|
|
46
|
+
case "marketplace":
|
|
47
|
+
out.push((await import("./publish-marketplace.js")).marketplaceTarget(d, deps));
|
|
48
|
+
break;
|
|
49
|
+
case "tauri-updater":
|
|
50
|
+
out.push((await import("./publish-tauri.js")).tauriUpdaterTarget(d, deps));
|
|
51
|
+
break;
|
|
37
52
|
}
|
|
38
53
|
}
|
|
39
54
|
return out;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Tauri updater target (#4676): the updater manifest a Tauri v2 app reads
|
|
3
|
+
* (`latest.json`), and a rolling GitHub release under a fixed tag, such as
|
|
4
|
+
* `app-latest`, that holds the release's bundles and that manifest. Each
|
|
5
|
+
* publish replaces what the rolling release held.
|
|
6
|
+
*
|
|
7
|
+
* The manifest is the updater's static JSON:
|
|
8
|
+
*
|
|
9
|
+
* ```json
|
|
10
|
+
* {
|
|
11
|
+
* "version": "1.4.0",
|
|
12
|
+
* "notes": "...",
|
|
13
|
+
* "pub_date": "2026-10-17T10:00:00.000Z",
|
|
14
|
+
* "platforms": {
|
|
15
|
+
* "darwin-aarch64": { "signature": "<the .sig file's text>", "url": "https://.../Acme_aarch64.app.tar.gz" }
|
|
16
|
+
* }
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* `version` is the release's label from its first digit on; `notes` is the
|
|
21
|
+
* text of the declared `notes` file, left out without one; `pub_date` is the
|
|
22
|
+
* time of the cut whose signature the publish carries, left out when none is
|
|
23
|
+
* known, so the manifest is the same bytes on every run. Each platform's
|
|
24
|
+
* `signature` is the text of the `.sig` file the Tauri build wrote beside its
|
|
25
|
+
* updater bundle, and `url` is the `url` pattern for that bundle, by default
|
|
26
|
+
* its download URL on the rolling release.
|
|
27
|
+
*
|
|
28
|
+
* GitHub can't replace a release's contents in one request, so the two steps
|
|
29
|
+
* (#4048) are a draft and a swap:
|
|
30
|
+
*
|
|
31
|
+
* - The stage makes a draft release for the rolling tag named
|
|
32
|
+
* `<tag> <version>` at the release's commit, or finds the one an earlier
|
|
33
|
+
* stage made, and uploads each bundle, each declared asset and the manifest
|
|
34
|
+
* to it. A file already on the draft with the same digest is not sent
|
|
35
|
+
* again; one that differs is refused (`publish-tauri-asset-exists`). The
|
|
36
|
+
* published rolling release is untouched, so the updater sees nothing new.
|
|
37
|
+
* A rolling release that already holds every file with the same digests is
|
|
38
|
+
* what an earlier reveal left, and the stage does nothing.
|
|
39
|
+
* - The reveal deletes the published rolling release, deletes the tag so it
|
|
40
|
+
* is made again at the release's commit, and publishes the draft with
|
|
41
|
+
* `make_latest` from `latest` (default `false`: a rolling release is not
|
|
42
|
+
* the repository's latest). Between the delete and the publish, a few
|
|
43
|
+
* requests apart, the rolling release's URLs answer 404, which an updater
|
|
44
|
+
* treats as no update.
|
|
45
|
+
*/
|
|
46
|
+
import type { TauriUpdaterPublishDeclaration } from "./publish-declaration.js";
|
|
47
|
+
import { type PublishDeps, type PublishTarget } from "./release-publish.js";
|
|
48
|
+
/** The first chant that publishes a `tauri-updater` target (#4676). */
|
|
49
|
+
export declare const PUBLISH_TAURI_UPDATER_FLOOR = "0.124.63";
|
|
50
|
+
/** The updater manifest's bytes: 2-space JSON with a trailing newline, keys in the order Tauri's docs show them. */
|
|
51
|
+
export declare function tauriManifest(m: {
|
|
52
|
+
version: string;
|
|
53
|
+
notes: string | null;
|
|
54
|
+
pubDate: string | null;
|
|
55
|
+
platforms: Record<string, {
|
|
56
|
+
signature: string;
|
|
57
|
+
url: string;
|
|
58
|
+
}>;
|
|
59
|
+
}): Uint8Array;
|
|
60
|
+
export declare function tauriUpdaterTarget(decl: TauriUpdaterPublishDeclaration, deps: PublishDeps): PublishTarget;
|
|
61
|
+
//# sourceMappingURL=publish-tauri.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish-tauri.d.ts","sourceRoot":"","sources":["../../src/lifecycle/publish-tauri.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAKH,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAC;AAI5E,OAAO,EAA2C,KAAK,WAAW,EAAuC,KAAK,aAAa,EAAqB,MAAM,mBAAmB,CAAC;AAE1K,uEAAuE;AACvE,eAAO,MAAM,2BAA2B,aAAa,CAAC;AAStD,oHAAoH;AACpH,wBAAgB,aAAa,CAAC,CAAC,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,GAAG,UAAU,CAK7K;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,8BAA8B,EAAE,IAAI,EAAE,WAAW,GAAG,aAAa,CA4HzG"}
|