Skip to content

Publish the VS Code extension with trusted publishing, then remove the registry tokens #589

Open

Description

@JuroOravec

The VS Code extension is published by .github/workflows/vscode--citry--publish.yml with two long-lived access tokens stored as repository secrets: OVSX_PAT for Open VSX and VSCE_PAT for the Visual Studio Marketplace. Both registries now let a GitHub Actions workflow publish with a short-lived token from GitHub's OIDC sign-in instead, so no token needs to be stored.

Open VSX

Open VSX added trusted publishing (wiki, implementation PR).

  1. On open-vsx.org, in the user settings, add a trusted publisher for the citry-dev namespace that names this repository and vscode--citry--publish.yml.
  2. In the promote job, add id-token: write to the permissions and publish with ovsx publish --trusted-publishing --skip-duplicate. The flag makes the command fail when no ID token is available, so it cannot fall back to a token silently.
  3. Drop the OVSX_PAT check from "Require registry credentials and read GitHub Release state".
  4. After a release publishes this way, delete the OVSX_PAT repository secret and revoke the Citry access token on open-vsx.org.

Visual Studio Marketplace

The Marketplace offers the same thing (publishing docs, announcement). On the citry-dev publisher page, a trusted publishing policy names the repository and workflow. The workflow then runs vsce publish --oidc, and the Marketplace issues a credential that lasts 15 minutes. Each GitHub OIDC token can be exchanged only once.

  1. Add the policy on the Marketplace publisher page.
  2. Switch the publish step to vsce publish --oidc --packagePath ... --skip-duplicate, and check that the locked @vscode/vsce version supports --oidc.
  3. Drop the VSCE_PAT check.
  4. After a release publishes this way, delete the VSCE_PAT secret and revoke the Azure DevOps token.

The older route, Entra ID workload identity with vsce publish --azure-credential, needs an Azure managed identity added to the publisher. Use it only if --oidc doesn't work for this publisher.

Note on the verify step

Open VSX now reviews a new version before serving it. For 0.3.0 that took longer than the verify step's five minutes (20 tries, 15 seconds apart), so the step failed after both uploads had succeeded, and the job was re-run by hand. While editing this workflow, give the Open VSX check a longer wait, or report a version that is still under review separately from one that is missing.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions