Skip to content

Commit 96f1831

Browse files
facundofariasclaude
andcommitted
ci: Switch to tag-based publishing workflow
Change from automatic publishing on main merge to tag-based releases for better control over when packages are published. Changes: - Update publish.yml to trigger on version tags (v*) - Add version validation (tag must match package.json) - Update workflow documentation with tag-based process - Add comprehensive RELEASING.md guide for maintainers Benefits: - Control when releases happen (not every merge) - Can batch multiple PRs into one release - Clear release process with version bumping - Standard practice in open source projects Publishing process: 1. npm version patch/minor/major 2. git push origin main --tags 3. GitHub Actions publishes automatically See RELEASING.md for complete release checklist. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 3d276a9 commit 96f1831

File tree

4 files changed

+286
-28
lines changed

4 files changed

+286
-28
lines changed

.github/workflows/README.md

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@ This repository uses GitHub Actions for continuous integration and automated npm
2121

2222
### 2. Publish Workflow (`publish.yml`)
2323

24-
**Triggers**: Automatically after CI workflow succeeds on `main` branch
24+
**Triggers**: When a version tag is pushed (e.g., `v1.0.0`)
2525

2626
**What it does**:
27-
1. Waits for CI workflow to complete successfully
28-
2. Checks out code and installs dependencies
29-
3. Builds the project
30-
4. Extracts version from `package.json`
27+
1. Checks out code and installs dependencies
28+
2. Builds the project
29+
3. Extracts version from `package.json`
30+
4. Verifies tag version matches package.json version
3131
5. Verifies package contents with `npm pack --dry-run`
3232
6. Publishes to npm registry (public package)
33-
7. Creates GitHub Release with tag `v{version}`
33+
7. Creates GitHub Release with version notes
3434

35-
**Dependencies**: Only runs if CI workflow passes
35+
**Note**: CI workflow should pass before creating release tags
3636

3737
## Setup Requirements
3838

@@ -58,32 +58,45 @@ The `GITHUB_TOKEN` is automatically provided by GitHub Actions - no setup needed
5858

5959
## Publishing Process
6060

61-
### Automatic Publishing (Recommended)
61+
### Tag-Based Publishing (Recommended)
6262

63-
When you merge to `main`:
63+
Releases are triggered by pushing version tags:
6464

6565
```bash
66-
# 1. Create PR with version bump
67-
git checkout -b release/v1.0.1
68-
npm version patch # or minor, major
69-
git push origin release/v1.0.1
66+
# 1. Ensure you're on main with latest changes
67+
git checkout main
68+
git pull origin main
69+
70+
# 2. Ensure CI is passing
71+
# Check: https://github.com/deployhq/deployhq-mcp-server/actions
72+
73+
# 3. Bump version in package.json
74+
npm version patch # 1.0.0 -> 1.0.1 (bug fixes)
75+
npm version minor # 1.0.0 -> 1.1.0 (new features)
76+
npm version major # 1.0.0 -> 2.0.0 (breaking changes)
77+
78+
# 4. Push commit and tag
79+
git push origin main
80+
git push origin --tags
7081

71-
# 2. Create and merge PR to main
7282
# GitHub Actions will automatically:
73-
# - Run CI tests
74-
# - Publish to npm (if CI passes)
83+
# - Build the project
84+
# - Verify tag matches package.json version
85+
# - Publish to npm
7586
# - Create GitHub release
7687
```
7788

7889
### Manual Publishing (Not Recommended)
7990

80-
If you need to publish manually:
91+
If automated publishing fails, you can publish manually:
8192

8293
```bash
8394
npm run build
8495
npm publish
8596
```
8697

98+
**Important**: Only use manual publishing as a last resort. The automated workflow is more reliable and creates proper GitHub releases.
99+
87100
## Version Management
88101

89102
Follow semantic versioning (SemVer):
@@ -118,15 +131,23 @@ Follow semantic versioning (SemVer):
118131
│ ├─ Test (108 tests) │
119132
│ ├─ Build │
120133
│ └─ Verify artifacts │
134+
└─────────────────────────────────────────────────────┘
135+
136+
(manually create release)
137+
138+
┌─────────────────────────────────────────────────────┐
139+
│ Developer creates version tag │
140+
│ $ npm version patch │
141+
│ $ git push origin main --tags │
121142
└────────────────┬────────────────────────────────────┘
122143
123-
│ (only on main branch)
124144
125145
┌─────────────────────────────────────────────────────┐
126146
│ Publish Workflow (publish.yml) │
127-
│ ├─ Wait for CI to succeed
147+
│ ├─ Triggered by version tag (v*)
128148
│ ├─ Build project │
129-
│ ├─ Verify package │
149+
│ ├─ Verify tag matches package.json │
150+
│ ├─ Verify package contents │
130151
│ ├─ Publish to npm │
131152
│ └─ Create GitHub Release │
132153
└─────────────────────────────────────────────────────┘

.github/workflows/publish.yml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
name: Publish to npm
22

33
on:
4-
workflow_run:
5-
workflows: ["CI"]
6-
types: [completed]
7-
branches: [main]
4+
push:
5+
tags:
6+
- 'v*' # Trigger on version tags like v1.0.0, v1.2.3, etc.
87

98
jobs:
109
publish:
1110
name: Publish to npm
1211
runs-on: ubuntu-latest
1312

14-
# Only run if CI workflow succeeded
15-
if: ${{ github.event.workflow_run.conclusion == 'success' }}
16-
1713
steps:
1814
- name: Checkout code
1915
uses: actions/checkout@v4
@@ -35,6 +31,16 @@ jobs:
3531
id: package-version
3632
run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
3733

34+
- name: Verify tag matches package version
35+
run: |
36+
TAG_VERSION=${GITHUB_REF#refs/tags/v}
37+
PACKAGE_VERSION=${{ steps.package-version.outputs.version }}
38+
if [ "$TAG_VERSION" != "$PACKAGE_VERSION" ]; then
39+
echo "Error: Git tag version ($TAG_VERSION) does not match package.json version ($PACKAGE_VERSION)"
40+
exit 1
41+
fi
42+
echo "✓ Tag version matches package.json version: $TAG_VERSION"
43+
3844
- name: Verify package contents
3945
run: |
4046
echo "Verifying package contents for v${{ steps.package-version.outputs.version }}..."

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,10 @@ Contributions are welcome! Please:
574574
4. Add tests if applicable
575575
5. Submit a pull request
576576

577+
### For Maintainers
578+
579+
See [RELEASING.md](RELEASING.md) for instructions on creating releases and publishing to npm.
580+
577581
## 📄 License
578582

579583
MIT License - see LICENSE file for details
@@ -582,7 +586,7 @@ MIT License - see LICENSE file for details
582586

583587
- **DeployHQ API Documentation**: https://www.deployhq.com/support/api
584588
- **MCP Documentation**: https://modelcontextprotocol.io
585-
- **Issues**: https://github.com/your-username/deployhq-mcp-server/issues
589+
- **Issues**: https://github.com/deployhq/deployhq-mcp-server/issues
586590

587591
## 🔗 Related Links
588592

RELEASING.md

Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
# Release Process
2+
3+
This document describes how to create a new release of the DeployHQ MCP Server.
4+
5+
## Prerequisites
6+
7+
Before creating a release, ensure you have:
8+
9+
- [ ] Maintainer access to the GitHub repository
10+
- [ ] npm publish access (verify with `npm whoami`)
11+
- [ ] Local `main` branch is up to date
12+
- [ ] All CI checks are passing on `main`
13+
14+
## Release Types
15+
16+
Follow [Semantic Versioning](https://semver.org/):
17+
18+
- **Patch** (`1.0.x`): Bug fixes, documentation updates, minor improvements
19+
- **Minor** (`1.x.0`): New features, non-breaking changes
20+
- **Major** (`x.0.0`): Breaking changes, major rewrites
21+
22+
## Release Checklist
23+
24+
### 1. Prepare the Release
25+
26+
```bash
27+
# Ensure you're on main with latest changes
28+
git checkout main
29+
git pull origin main
30+
31+
# Verify CI is passing
32+
# Check: https://github.com/deployhq/deployhq-mcp-server/actions
33+
34+
# Run tests locally
35+
npm test
36+
37+
# Build locally to verify
38+
npm run build
39+
```
40+
41+
### 2. Update Version and Changelog
42+
43+
```bash
44+
# Choose the appropriate version bump
45+
npm version patch # For bug fixes (1.0.0 -> 1.0.1)
46+
npm version minor # For new features (1.0.0 -> 1.1.0)
47+
npm version major # For breaking changes (1.0.0 -> 2.0.0)
48+
49+
# This will:
50+
# - Update package.json version
51+
# - Create a git commit "1.0.1"
52+
# - Create a git tag "v1.0.1"
53+
```
54+
55+
**Optional**: Update CHANGELOG.md with release notes before running `npm version`.
56+
57+
### 3. Push Changes and Tags
58+
59+
```bash
60+
# Push the version commit
61+
git push origin main
62+
63+
# Push the version tag (triggers publish workflow)
64+
git push origin --tags
65+
```
66+
67+
### 4. Monitor the Release
68+
69+
1. **Watch GitHub Actions**: https://github.com/deployhq/deployhq-mcp-server/actions
70+
- Wait for "Publish to npm" workflow to complete
71+
- Should take ~2-3 minutes
72+
73+
2. **Verify npm Publication**: https://www.npmjs.com/package/deployhq-mcp-server
74+
- Check that new version appears
75+
- Verify package contents are correct
76+
77+
3. **Check GitHub Release**: https://github.com/deployhq/deployhq-mcp-server/releases
78+
- Verify release was created automatically
79+
- Edit release notes if needed
80+
81+
### 5. Verify the Release
82+
83+
```bash
84+
# Test installing from npm
85+
npx deployhq-mcp-server@latest --version
86+
87+
# Or install in a test project
88+
mkdir test-install && cd test-install
89+
npm init -y
90+
npm install deployhq-mcp-server
91+
node -e "import('deployhq-mcp-server')"
92+
```
93+
94+
### 6. Announce the Release (Optional)
95+
96+
If it's a significant release:
97+
- Update README.md if needed
98+
- Post announcement (Discord, Twitter, etc.)
99+
- Update documentation site
100+
101+
## Troubleshooting
102+
103+
### Publish Workflow Failed
104+
105+
**Check the logs**:
106+
```bash
107+
# View workflow runs
108+
https://github.com/deployhq/deployhq-mcp-server/actions
109+
```
110+
111+
**Common issues**:
112+
113+
1. **Tag version mismatch**
114+
- Error: "Git tag version does not match package.json version"
115+
- Fix: Ensure tag and package.json versions match
116+
```bash
117+
# Delete the tag locally and remotely
118+
git tag -d v1.0.1
119+
git push origin :refs/tags/v1.0.1
120+
121+
# Fix package.json version and create tag again
122+
npm version 1.0.1
123+
git push origin main --tags
124+
```
125+
126+
2. **npm publish failed - version already exists**
127+
- Error: "Cannot publish over existing version"
128+
- Fix: Version was already published, bump to next version
129+
```bash
130+
npm version patch
131+
git push origin main --tags
132+
```
133+
134+
3. **npm publish failed - authentication**
135+
- Error: "authentication failed"
136+
- Fix: Check NPM_TOKEN secret in GitHub
137+
- Go to: Settings → Secrets → Actions → NPM_TOKEN
138+
- Regenerate token: `npm token create --type automation`
139+
140+
4. **Build failed**
141+
- Run build locally to diagnose: `npm run build`
142+
- Fix issues and commit to main
143+
- Delete failed tag and recreate
144+
145+
### Manual Rollback
146+
147+
If a published version has critical issues:
148+
149+
```bash
150+
# Deprecate the broken version on npm
151+
npm deprecate [email protected] "Critical bug, use 1.0.2 instead"
152+
153+
# Create a hotfix release
154+
npm version patch
155+
git push origin main --tags
156+
```
157+
158+
**Note**: You cannot unpublish versions after 72 hours. Use deprecation instead.
159+
160+
### Manual Publishing (Emergency Only)
161+
162+
If the automated workflow is broken:
163+
164+
```bash
165+
# Ensure you're logged in
166+
npm whoami
167+
168+
# Build the project
169+
npm run build
170+
171+
# Publish manually
172+
npm publish
173+
174+
# Manually create GitHub release
175+
# Go to: https://github.com/deployhq/deployhq-mcp-server/releases/new
176+
```
177+
178+
## Version History
179+
180+
Track versions and release dates:
181+
182+
| Version | Date | Type | Notes |
183+
|---------|------|------|-------|
184+
| 1.0.0 | 2025-11-11 | Initial | First stable release |
185+
186+
## Best Practices
187+
188+
### DO:
189+
- ✅ Always run tests before releasing
190+
- ✅ Ensure CI passes before tagging
191+
- ✅ Test the package after publishing
192+
- ✅ Use semantic versioning correctly
193+
- ✅ Write clear release notes
194+
- ✅ Batch multiple small changes into one release
195+
196+
### DON'T:
197+
- ❌ Force push to main
198+
- ❌ Delete published npm versions (use deprecate)
199+
- ❌ Skip version bumps in package.json
200+
- ❌ Publish breaking changes as patches
201+
- ❌ Release on Friday afternoon (Murphy's Law)
202+
203+
## Release Cadence
204+
205+
**Suggested schedule**:
206+
- **Patch releases**: As needed for bugs (any time)
207+
- **Minor releases**: Weekly or bi-weekly for features
208+
- **Major releases**: Quarterly or when necessary for breaking changes
209+
210+
## Questions?
211+
212+
- Check `.github/workflows/README.md` for CI/CD details
213+
- Check `package.json` for current version
214+
- Check GitHub Actions for workflow status
215+
- Check npm for published versions
216+
217+
## Quick Reference
218+
219+
```bash
220+
# Complete release in 4 commands
221+
git checkout main && git pull
222+
npm version patch
223+
git push origin main
224+
git push origin --tags
225+
```
226+
227+
Then monitor: https://github.com/deployhq/deployhq-mcp-server/actions

0 commit comments

Comments
 (0)