Authentication Methods
Codemod supports three authentication methods for publishing:| Method | Best For | Secrets Required | Setup |
|---|---|---|---|
| Interactive Login | Local development | None | None |
| API Keys | CI/CD pipelines, automation | Yes (CODEMOD_API_KEY) | Create key in UI |
| Trusted Publishers | GitHub Actions, secure CI/CD | None (uses OIDC) | None for org scopes* |
Interactive Login
The simplest way to authenticate for local development. Opens a browser for OAuth authentication.When to Use
- Local development and testing
- Quick one-off publishes
- When you prefer browser-based authentication
Trusted Publishers
Trusted publishers enable passwordless publishing from GitHub Actions using OpenID Connect (OIDC). No secrets to manage or rotate.How OIDC Works
GitHub Actions can request short-lived tokens that cryptographically prove the workflow’s identity. Codemod verifies these tokens against your configured trusted publishers.
Benefits
- No secrets to manage: No API keys to create, rotate, or accidentally leak
- Cryptographically secure: Tokens are signed by GitHub and verified by Codemod
- Fine-grained control: Restrict publishing by repository, workflow, environment, or git ref
- Short-lived tokens: Tokens expire in ~5 minutes, limiting exposure
Organization Scopes (Zero Configuration)
This is the recommended approach for organizations. If your GitHub organization name matches your package scope, trusted publishing works automatically with no UI configuration needed.
@my-org/my-codemod), trusted publishers work automatically when:
- Your GitHub organization name matches the package scope (e.g., GitHub org
my-org→ scope@my-org) - You’ve linked your GitHub organization (see setup steps below)
Linking Your GitHub Organization
To enable automatic trusted publishing for your organization scope, you need to install the Codemod GitHub App:1
Install the Codemod GitHub App
- Install the Codemod GitHub App and select your GitHub organization (requires org admin permissions)
- Grant access to at least one repository
2
Sign in to Codemod
Go to Codemod platform and sign in with GitHub. Your organization will be automatically linked.
workflow_dispatch) in your organization’s repositories can publish codemods under that scope. The publisher identity in Codemod’s system is tied to the user who installed the GitHub App.
Complete GitHub Actions Workflow
Here’s a complete workflow file for publishing. You can create this manually or usecodemod init to generate it automatically:
For a single codemod repository:
codemods/ directory), use tags like [email protected]:
npx codemod init to generate this workflow automatically. It creates the single-codemod or monorepo format based on your project structure.
Individual Packages (Manual Configuration)
For unscoped packages or cases where the GitHub org doesn’t match the package scope, configure a trusted publisher manually:1
Configure Trusted Publisher in UI
- Go to codemod.com/api-keys
- Scroll to Trusted Publishers
- Click Add Trusted Publisher
- Select your package and enter the GitHub repository details
- (Optional) Add restrictions for extra security
2
Configure Your Workflow
| Field | Description | Example |
|---|---|---|
| Package | The package to publish to (required) | my-codemod or @org/my-codemod |
| Repository Owner | GitHub org or username | my-org |
| Repository Name | Repository name | my-codemod-repo |
Optional Restrictions
Add restrictions for additional security:| Restriction | Description | Example |
|---|---|---|
| Workflow Path | Only allow specific workflow files | .github/workflows/publish.yml |
| Environment | Require GitHub Environment approval | production |
| Ref Pattern | Only allow specific git refs | refs/tags/v* |
Manual OIDC Setup
If you prefer not to use the action, you can manually obtain and use the OIDC token:Troubleshooting
No trusted publisher found
No trusted publisher found
Verify your trusted publisher configuration matches:
- Repository owner (case-insensitive)
- Repository name (exact match)
- Any configured restrictions (workflow path, environment, ref pattern)
Permission denied
Permission denied
Ensure your workflow has the required permissions:
Token audience mismatch
Token audience mismatch
The OIDC token audience must be
https://codemod.com. If using a custom registry, configure GITHUB_OIDC_AUDIENCE on the server.API Keys
API keys allow non-interactive authentication, perfect for CI/CD pipelines and automation.Creating an API Key
- Go to codemod.com/api-keys
- Click Create API Key
- Give it a descriptive name (e.g., “GitHub Actions - my-repo”)
- Select the permissions (typically “Publish Packages”)
- Copy the key (it won’t be shown again)
Using API Keys
Option 1: Login with API keyGitHub Actions Example
When to Use
- CI/CD pipelines without GitHub Actions OIDC
- GitLab CI, CircleCI, Jenkins, etc.
- Automated publishing from any environment
- When you need explicit control over credentials
Comparison
| Feature | Interactive Login | API Keys | Trusted Publishers |
|---|---|---|---|
| Secrets to manage | None | Yes | None |
| Works locally | Yes | Yes | No |
| Works in CI/CD | No | Yes | GitHub Actions only |
| New package publish | Yes | Yes | Yes* |
| Token lifetime | Long-lived | Long-lived | ~5 minutes |
| Rotation needed | No | Recommended | No |
| UI configuration | None | Create key | None for org scopes** |
Best Practices
Use Trusted Publishers
For GitHub Actions, prefer trusted publishers over API keys. No secrets to leak or rotate.
Restrict Access
When using trusted publishers, add restrictions like environment protection for sensitive packages.
Rotate API Keys
If using API keys, rotate them periodically and use the minimum required permissions.
Tag Releases
Use git tags and GitHub releases to trigger publish workflows for clear version history.