11# Auto-Publishing Setup
22
3- This repository includes two auto-publishing workflows for different use cases:
4-
5- 1 . ** Direct Auto-Publish** : Automatically publishes when changes are pushed to ` main `
6- 2 . ** PR-based Auto-Publish** : Detects changes in PRs and waits for maintainer approval
7-
8- Both workflows publish codemods from the ` recipes/ ` directory to the Codemod Registry.
3+ This repository includes an auto-publishing workflow that automatically publishes codemods to the Codemod Registry when changes are merged to ` main ` .
94
105## Quick Setup
116
1271 . ** Get API key** : [ https://app.codemod.com/api-keys ] ( https://app.codemod.com/api-keys )
13- 2 . ** Run setup script** :
14- ``` bash
15- ./scripts/setup-auto-publish.sh
16- ```
17-
18- The script will ask for your API key, registry scope (e.g., ` your-org ` ), and registry URL.
8+ 2 . ** Create GitHub Environment** (required for secrets):
9+ - Go to your repository β Settings β Environments
10+ - Click "New environment"
11+ - Name it ` production ` (or any name you prefer)
12+ - Click "Configure environment"
13+ 3 . ** Add secrets to the environment** :
14+ - In the environment settings, add these secrets:
15+ - ` CODEMOD_API_KEY ` : Your API key from step 1
16+ - Optionally add these variables:
17+ - ` CODEMOD_REGISTRY_SCOPE ` : Your organization scope (e.g., ` your-org ` )
18+ - ` CODEMOD_REGISTRY_URL ` : Registry URL (defaults to ` https://registry.codemod.com ` )
1919
2020## How It Works
2121
22- ### Direct Auto-Publish (Default)
22+ ### Auto-Publish Workflow
2323- ** Trigger** : Push to ` main ` branch
24- - ** Process** : Automatically detects changes and publishes
25- - ** Best for** : Solo maintainers or trusted teams
24+ - ** Process** :
25+ 1 . Automatically detects changes in ` recipes/ ` directory
26+ 2 . Publishes new/updated codemods to the registry
27+ 3 . Unpublishes removed codemods
28+ 4 . Auto-resolves version conflicts (bumps patch version)
2629
27- ### PR-based Auto-Publish (Recommended for Open Source)
30+ ### PR Detection Workflow
2831- ** Trigger** : Pull request with codemod changes
2932- ** Process** :
3033 1 . Bot detects changed codemods in PR
31- 2 . Posts comment with pre-filled publish commands
32- 3 . Waits for maintainer approval (thumbs up reaction)
33- 4 . Executes publishing commands when approved
34- - ** Best for** : Open source projects with community contributions
34+ 2 . Posts comment: "Codemods will be auto-published on merge to main"
35+ 3 . No action required - just merge the PR
3536
36- ### Common Features
37+ ### Features
3738- ** New codemods** : Published for the first time
3839- ** Updated codemods** : Version bumped and republished
3940- ** Removed codemods** : Automatically unpublished
@@ -51,40 +52,32 @@ The script will ask for your API key, registry scope (e.g., `your-org`), and reg
5152- Never exposed in code, logs, or documentation
5253- Only GitHub Actions can access the key
5354
54- ## Manual Setup
55-
56- If you prefer manual setup:
57-
58- 1 . ** GitHub Secrets** : ` CODEMOD_API_KEY ` (your API key)
59- 2 . ** GitHub Variables** :
60- - ` CODEMOD_REGISTRY_SCOPE ` (your organization scope)
61- - ` CODEMOD_REGISTRY_URL ` (registry URL, optional)
62-
6355## Examples
6456
65- ### Direct Auto-Publish
57+ ### Auto-Publish on Merge
6658``` bash
67- # 1. Make changes
59+ # 1. Make changes to codemod
6860echo " console.log('test');" > recipes/my-codemod/tests/input.js
6961
70- # 2. Commit and push
62+ # 2. Create PR
7163git add recipes/my-codemod/
7264git commit -m " Add test case"
65+ git push origin feature-branch
66+ # Create PR on GitHub
67+
68+ # 3. Bot comments: "Codemods will be auto-published on merge to main"
69+
70+ # 4. Merge PR to main
71+ git checkout main
72+ git merge feature-branch
7373git push origin main
7474
75- # 3 . GitHub Actions automatically publishes to registry
76- # 4 . Available at: https://registry.codemod.com/@your-scope/my-codemod
75+ # 5 . GitHub Actions automatically publishes to registry
76+ # 6 . Available at: https://registry.codemod.com/@your-scope/my-codemod
7777```
7878
79- ### PR-based Auto-Publish
80- ``` bash
81- # 1. Community contributor opens PR with codemod changes
82- # 2. Bot automatically posts comment:
83- # "Show a thumbs up to this comment and I'll run:
84- # git tag -a v1.0.0@my-codemod -m 'Release version v1.0.0 for my-codemod'
85- # git push origin --tags"
86-
87- # 3. Maintainer reviews and gives thumbs up π
88- # 4. Bot executes commands and updates comment with success
89- # 5. Codemod is published to registry
90- ```
79+ ### Environment Setup Screenshots
80+ 1 . ** Repository Settings** β ** Environments** β ** New environment**
81+ 2 . ** Name** : ` production ` β ** Configure environment**
82+ 3 . ** Add secrets** : ` CODEMOD_API_KEY ` with your API key
83+ 4 . ** Add variables** (optional): ` CODEMOD_REGISTRY_SCOPE ` , ` CODEMOD_REGISTRY_URL `
0 commit comments