Skip to content

Commit 5dfaf6e

Browse files
committed
update auto publish
1 parent d9dc5ca commit 5dfaf6e

File tree

3 files changed

+46
-52
lines changed

3 files changed

+46
-52
lines changed

β€Ž.github/workflows/auto-publish.ymlβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ on:
1111
jobs:
1212
auto-publish:
1313
runs-on: ubuntu-latest
14+
environment: production
1415

1516
steps:
1617
- name: Checkout code

β€ŽAUTO_PUBLISH_SETUP.mdβ€Ž

Lines changed: 40 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,40 @@
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

127
1. **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
6860
echo "console.log('test');" > recipes/my-codemod/tests/input.js
6961

70-
# 2. Commit and push
62+
# 2. Create PR
7163
git add recipes/my-codemod/
7264
git 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
7373
git 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`

β€ŽREADME.mdβ€Ž

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ This template repository comes pre-configured with a GitHub workflow that automa
3030
>
3131
> 6. Set up auto-publishing to [Codemod Registry](https://app.codemod.com/registry):
3232
>
33-
> ```bash
34-
> # Get API key from https://app.codemod.com/api-keys
35-
> ./scripts/setup-auto-publish.sh
36-
> ```
33+
> 1. **Get API key**: [https://app.codemod.com/api-keys](https://app.codemod.com/api-keys)
34+
> 2. **Create GitHub Environment**: Repository Settings β†’ Environments β†’ New environment (name it `production`)
35+
> 3. **Add secret**: `CODEMOD_API_KEY` with your API key
36+
> 4. **Optional variables**: `CODEMOD_REGISTRY_SCOPE`, `CODEMOD_REGISTRY_URL`
3737
>
38-
> This automatically publishes codemods when you push changes to `recipes/`. See [AUTO_PUBLISH_SETUP.md](./AUTO_PUBLISH_SETUP.md) for details.
38+
> This automatically publishes codemods when you merge changes to `main`. See [AUTO_PUBLISH_SETUP.md](./AUTO_PUBLISH_SETUP.md) for details.
3939
4040
4141
## Overview

0 commit comments

Comments
Β (0)