|
| 1 | +# GitHub Actions Publishing Guide |
| 2 | + |
| 3 | +## 🚀 Automated NPM Publishing |
| 4 | + |
| 5 | +This repository includes a GitHub Actions workflow that allows you to publish packages to NPM with manual triggering. |
| 6 | + |
| 7 | +### 📋 Workflow Features |
| 8 | + |
| 9 | +- **Manual Trigger**: Choose when to publish |
| 10 | +- **Registry Selection**: Public NPM or GitHub Packages |
| 11 | +- **Custom Suffix**: Define package naming (e.g., `openshift-ai`) |
| 12 | +- **Version Management**: Automatic version from git tags |
| 13 | +- **Multi-Platform**: Publishes all platform-specific packages |
| 14 | +- **Security**: Uses encrypted secrets for authentication |
| 15 | + |
| 16 | +### 🔧 Setup Required |
| 17 | + |
| 18 | +#### 1. Repository Secrets |
| 19 | +Go to **Settings → Secrets and variables → Actions** and add: |
| 20 | + |
| 21 | +**For Public NPM Publishing:** |
| 22 | +- `NPM_TOKEN`: Your npm access token with publish permissions |
| 23 | + |
| 24 | +**For GitHub Packages Publishing:** |
| 25 | +- `GITHUB_TOKEN`: Your GitHub personal access token with `write:packages` scope |
| 26 | + |
| 27 | +#### 2. Token Creation |
| 28 | + |
| 29 | +**Public NPM Token:** |
| 30 | +1. Go to [npmjs.com](https://www.npmjs.com/settings/tokens) |
| 31 | +2. Click "Generate New Token" |
| 32 | +3. Select "Automation" type |
| 33 | +4. Enable "Publish" permissions |
| 34 | +5. Copy the token |
| 35 | + |
| 36 | +**GitHub Token:** |
| 37 | +1. Go to [GitHub Settings](https://github.com/settings/tokens) |
| 38 | +2. Click "Generate new token (classic)" |
| 39 | +3. Select scopes: `repo`, `write:packages` |
| 40 | +4. Copy the token |
| 41 | + |
| 42 | +### 🎮 How to Use |
| 43 | + |
| 44 | +#### 1. Go to Actions |
| 45 | +1. Navigate to **Actions** tab in your repository |
| 46 | +2. Select **"Publish to NPM"** workflow from the left sidebar |
| 47 | +3. Click **"Run workflow"** button |
| 48 | + |
| 49 | +#### 2. Configure Publishing |
| 50 | +Fill in the workflow parameters: |
| 51 | + |
| 52 | +- **registry**: Choose `public` or `github-packages` |
| 53 | +- **suffix**: Enter your package suffix (e.g., `openshift-ai`) |
| 54 | + |
| 55 | +#### 3. Run and Monitor |
| 56 | +1. Click **"Run workflow"** to start publishing |
| 57 | +2. Monitor progress in real-time |
| 58 | +3. Check the summary for installation instructions |
| 59 | + |
| 60 | +### 📦 Publishing Options |
| 61 | + |
| 62 | +#### Option 1: Public NPM Registry |
| 63 | +- **Registry**: `https://registry.npmjs.org/` |
| 64 | +- **Package Name**: `kubernetes-mcp-server-{suffix}` |
| 65 | +- **Installation**: `npm install kubernetes-mcp-server-{suffix}` |
| 66 | +- **Visibility**: Public to everyone |
| 67 | + |
| 68 | +#### Option 2: GitHub Packages Registry |
| 69 | +- **Registry**: `https://npm.pkg.github.com/` |
| 70 | +- **Package Name**: `@macayaven/kubernetes-mcp-server` |
| 71 | +- **Installation**: Requires registry configuration |
| 72 | +- **Visibility**: Private to your account |
| 73 | + |
| 74 | +### 🔄 Workflow Process |
| 75 | + |
| 76 | +1. **Checkout**: Downloads your code |
| 77 | +2. **Setup**: Configures Node.js and Go |
| 78 | +3. **Configure**: Sets up NPM registry and authentication |
| 79 | +4. **Version**: Gets version from git tags |
| 80 | +5. **Prepare**: Runs `prepare-fork-npm.sh` with your suffix |
| 81 | +6. **Build**: Compiles binaries for all platforms |
| 82 | +7. **Copy**: Moves binaries to npm packages |
| 83 | +8. **Publish**: Uploads all packages to NPM |
| 84 | +9. **Summary**: Creates GitHub Actions summary |
| 85 | + |
| 86 | +### 📊 What Gets Published |
| 87 | + |
| 88 | +#### Platform Packages (7 total) |
| 89 | +- `kubernetes-mcp-server-{suffix}-darwin-amd64` |
| 90 | +- `kubernetes-mcp-server-{suffix}-darwin-arm64` |
| 91 | +- `kubernetes-mcp-server-{suffix}-linux-amd64` |
| 92 | +- `kubernetes-mcp-server-{suffix}-linux-arm64` |
| 93 | +- `kubernetes-mcp-server-{suffix}-windows-amd64` |
| 94 | +- `kubernetes-mcp-server-{suffix}-windows-arm64` |
| 95 | + |
| 96 | +#### Main Package (1 total) |
| 97 | +- `kubernetes-mcp-server-{suffix}` (with optionalDependencies) |
| 98 | + |
| 99 | +### 🎯 Example Usage |
| 100 | + |
| 101 | +#### Publishing to Public NPM with OpenShift AI suffix: |
| 102 | +1. **Run workflow** with: |
| 103 | + - registry: `public` |
| 104 | + - suffix: `openshift-ai` |
| 105 | + |
| 106 | +2. **Result**: Users can install with: |
| 107 | + ```bash |
| 108 | + npm install kubernetes-mcp-server-openshift-ai |
| 109 | + ``` |
| 110 | + |
| 111 | +#### Publishing to GitHub Packages: |
| 112 | +1. **Run workflow** with: |
| 113 | + - registry: `github-packages` |
| 114 | + - suffix: `openshift-ai` |
| 115 | + |
| 116 | +2. **Result**: Users can install with: |
| 117 | + ```bash |
| 118 | + npm config set @macayaven:registry https://npm.pkg.github.com/ |
| 119 | + npm install @macayaven/kubernetes-mcp-server |
| 120 | + ``` |
| 121 | + |
| 122 | +### 🔍 Troubleshooting |
| 123 | + |
| 124 | +#### Common Issues |
| 125 | + |
| 126 | +**Authentication Failed (401/403)** |
| 127 | +- Check that secrets are correctly set |
| 128 | +- Verify tokens have required permissions |
| 129 | +- Ensure tokens haven't expired |
| 130 | + |
| 131 | +**Publish Failed (409 Conflict)** |
| 132 | +- Version already exists |
| 133 | +- Check if you need to increment version |
| 134 | +- Git tag may already be published |
| 135 | + |
| 136 | +**Build Failed** |
| 137 | +- Check workflow logs for build errors |
| 138 | +- Ensure Go version compatibility |
| 139 | +- Verify all dependencies are available |
| 140 | + |
| 141 | +**Registry Configuration Error** |
| 142 | +- Verify registry URL is correct |
| 143 | +- Check .npmrc file format |
| 144 | +- Ensure token is properly encoded |
| 145 | + |
| 146 | +### 📝 Workflow File |
| 147 | + |
| 148 | +The workflow is defined in `.github/workflows/publish-npm.yml` and includes: |
| 149 | + |
| 150 | +- **Manual triggering** with configurable parameters |
| 151 | +- **Multi-platform support** for all major OS/architectures |
| 152 | +- **Security best practices** using GitHub secrets |
| 153 | +- **Comprehensive logging** and error handling |
| 154 | +- **Automatic summaries** with installation instructions |
| 155 | + |
| 156 | +### 🎉 Benefits |
| 157 | + |
| 158 | +- **One-click publishing** - no local setup required |
| 159 | +- **Consistent process** - same steps every time |
| 160 | +- **Version management** - automatic from git tags |
| 161 | +- **Multi-registry support** - public npm or GitHub Packages |
| 162 | +- **Security** - tokens encrypted and managed by GitHub |
| 163 | +- **Transparency** - full logs and progress tracking |
| 164 | + |
| 165 | +### 📚 Additional Resources |
| 166 | + |
| 167 | +- [GitHub Actions Documentation](https://docs.github.com/en/actions) |
| 168 | +- [NPM Documentation](https://docs.npmjs.com/) |
| 169 | +- [Semantic Versioning](https://semver.org/) |
| 170 | +- [OpenShift AI Documentation](https://docs.redhat.com/en-us/openshift_data_science/) |
| 171 | + |
| 172 | +--- |
| 173 | + |
| 174 | +*This workflow makes publishing your OpenShift AI enhanced MCP server as simple as clicking a button!* 🚀 |
0 commit comments