Skip to content

Commit f30e593

Browse files
committed
add actions
1 parent c74ec71 commit f30e593

File tree

5 files changed

+239
-7
lines changed

5 files changed

+239
-7
lines changed

.github/workflows/ci.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: '20'
20+
cache: 'npm'
21+
22+
- name: Install dependencies
23+
run: npm ci
24+
25+
- name: Build
26+
run: npm run build
27+
28+
- name: Test
29+
run: npm test
30+
31+
- name: Generate documentation
32+
run: npm run docs

.github/workflows/release.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
with:
14+
fetch-depth: 0
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: '20'
20+
registry-url: 'https://registry.npmjs.org'
21+
22+
- name: Install dependencies
23+
run: npm ci
24+
25+
- name: Build
26+
run: npm run build
27+
28+
- name: Test
29+
run: npm test
30+
31+
- name: Create Release
32+
id: create_release
33+
uses: softprops/action-gh-release@v1
34+
with:
35+
name: Release ${{ github.ref_name }}
36+
draft: false
37+
prerelease: false
38+
generate_release_notes: true
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
42+
- name: Publish to NPM
43+
run: |
44+
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc
45+
npm publish --access public
46+
env:
47+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ A TypeScript library for performing arithmetic and comparison operations on Kube
1414
## Installation
1515

1616
```bash
17-
npm install k8s-resources
17+
npm install @kotaicodegmbh/k8s-resources
1818
```
1919

2020
## Usage
2121

2222
### CPU Resources
2323

2424
```typescript
25-
import { CPUResource } from 'k8s-resources';
25+
import { CPUResource, MemoryResource } from '@kotaicodegmbh/k8s-resources';
2626

2727
// Create CPU resources
2828
const cpu1 = new CPUResource('100m'); // 100 millicores
@@ -48,7 +48,7 @@ console.log(cpu2.toString()); // "1"
4848
### Memory Resources
4949

5050
```typescript
51-
import { MemoryResource } from 'k8s-resources';
51+
import { MemoryResource } from '@kotaicodegmbh/k8s-resources';
5252

5353
// Create memory resources
5454
const mem1 = new MemoryResource('128Mi'); // 128 mebibytes
@@ -180,6 +180,14 @@ The API documentation will be generated in the `docs/api` directory. The documen
180180
- Error documentation
181181
- Cross-references between related components
182182

183+
## Contributing
184+
185+
1. Fork the repository
186+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
187+
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
188+
4. Push to the branch (`git push origin feature/amazing-feature`)
189+
5. Open a Pull Request
190+
183191
## License
184192

185193
MIT

docs/release.md

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# Release Guide
2+
3+
This guide explains how to set up your NPM account and create releases for the `@kotaicodegmbh/k8s-resources` package.
4+
5+
## Prerequisites
6+
7+
1. Node.js and npm installed on your system
8+
2. Git installed and configured
9+
3. A GitHub account with access to the repository
10+
4. An NPM account
11+
12+
## Setting Up NPM
13+
14+
### 1. Create an NPM Account
15+
16+
If you don't have an NPM account:
17+
18+
1. Visit [npmjs.com](https://npmjs.com)
19+
2. Click "Sign Up"
20+
3. Follow the registration process
21+
4. Verify your email address
22+
23+
### 2. Create an NPM Organization
24+
25+
1. Log in to your NPM account
26+
2. Go to [npmjs.com/org/create](https://npmjs.com/org/create)
27+
3. Create an organization named "kotaicodegmbh"
28+
4. Choose the "Free" plan
29+
5. Add your account as an owner
30+
31+
### 3. Generate an NPM Access Token
32+
33+
1. Log in to your NPM account
34+
2. Click on your profile picture → "Access Tokens"
35+
3. Click "Generate New Token"
36+
4. Select "Automation" token type
37+
5. Copy the generated token (you won't be able to see it again)
38+
39+
### 4. Add NPM Token to GitHub Secrets
40+
41+
1. Go to your GitHub repository
42+
2. Navigate to Settings → Secrets and Variables → Actions
43+
3. Click "New repository secret"
44+
4. Name: `NPM_TOKEN`
45+
5. Value: Paste your NPM access token
46+
6. Click "Add secret"
47+
48+
## Creating a Release
49+
50+
### 1. Update Version
51+
52+
Update the version in `package.json`:
53+
54+
```bash
55+
npm version patch # for bug fixes (0.0.X)
56+
npm version minor # for new features (0.X.0)
57+
npm version major # for breaking changes (X.0.0)
58+
```
59+
60+
This will:
61+
- Update the version in `package.json`
62+
- Create a git commit
63+
- Create a git tag
64+
65+
### 2. Push Changes
66+
67+
Push your changes and the new tag to GitHub:
68+
69+
```bash
70+
git push origin main
71+
git push origin --tags
72+
```
73+
74+
### 3. Release Process
75+
76+
The GitHub Actions workflow will automatically:
77+
78+
1. Run tests
79+
2. Build the package
80+
3. Create a GitHub release with auto-generated notes
81+
4. Publish to NPM as `@kotaicodegmbh/k8s-resources`
82+
83+
You can monitor the release progress in:
84+
- GitHub Actions tab
85+
- GitHub Releases page
86+
- NPM package page
87+
88+
## Verifying the Release
89+
90+
### 1. Check GitHub Release
91+
92+
1. Go to your repository's "Releases" page
93+
2. Verify the new release is listed
94+
3. Check the release notes are accurate
95+
96+
### 2. Check NPM Package
97+
98+
1. Visit [npmjs.com/package/@kotaicodegmbh/k8s-resources](https://npmjs.com/package/@kotaicodegmbh/k8s-resources)
99+
2. Verify the new version is listed
100+
3. Check the package details
101+
102+
### 3. Test Installation
103+
104+
Test the package installation in a new project:
105+
106+
```bash
107+
npm install @kotaicodegmbh/k8s-resources
108+
```
109+
110+
## Troubleshooting
111+
112+
### Common Issues
113+
114+
1. **NPM Authentication Failed**
115+
- Verify your NPM token is correctly set in GitHub secrets
116+
- Check if your NPM account has access to the organization
117+
118+
2. **Release Failed**
119+
- Check GitHub Actions logs for error messages
120+
- Verify all tests pass locally
121+
- Ensure the version number is unique
122+
123+
3. **Package Not Published**
124+
- Verify the NPM token has publish permissions
125+
- Check if the package name is available
126+
- Ensure the organization exists and you have access
127+
128+
### Getting Help
129+
130+
If you encounter issues:
131+
132+
1. Check the [GitHub Actions documentation](https://docs.github.com/en/actions)
133+
2. Review the [NPM documentation](https://docs.npmjs.com/)
134+
3. Open an issue in the repository

package.json

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
2-
"name": "k8s-resources",
2+
"name": "@kotaicodegmbh/k8s-resources",
33
"version": "1.0.0",
44
"description": "A TypeScript library for performing arithmetic and comparison operations on Kubernetes CPU and memory resources",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",
7-
"module": "dist/index.js",
87
"files": [
9-
"dist"
8+
"dist",
9+
"README.md"
1010
],
1111
"scripts": {
1212
"build": "tsc",
@@ -22,8 +22,19 @@
2222
"arithmetic",
2323
"typescript"
2424
],
25-
"author": "",
25+
"author": "Kotaicode",
2626
"license": "MIT",
27+
"repository": {
28+
"type": "git",
29+
"url": "git+https://github.com/kotaicode/k8s-resources-ts.git"
30+
},
31+
"bugs": {
32+
"url": "https://github.com/kotaicode/k8s-resources-ts/issues"
33+
},
34+
"homepage": "https://github.com/kotaicode/k8s-resources-ts#readme",
35+
"publishConfig": {
36+
"access": "public"
37+
},
2738
"devDependencies": {
2839
"@types/jest": "^29.5.12",
2940
"@types/node": "^20.11.24",

0 commit comments

Comments
 (0)