Skip to content

Commit e079ff7

Browse files
committed
Update package.json and add GitHub Actions workflows
Package.json updates: - Remove invalid "main" field (CLI tool, not a library) - Add repository information - Set private: false for npm publishing - Update test script to use ./test.sh - Add author: ServiceStack - Add keywords: cli, generator GitHub Actions workflows: - Add ci.yml: Runs tests on push/PR for Node 14, 16, 18, 20 - Add publish.yml: Auto-publish to npm on GitHub releases - Add workflows/README.md: Documentation for publishing process Publishing documentation: - Update README with automated publishing instructions - Add manual publishing instructions - Document npm version bumping process - Link to workflows documentation
1 parent 166c5fb commit e079ff7

File tree

5 files changed

+174
-5
lines changed

5 files changed

+174
-5
lines changed

.github/workflows/README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# GitHub Actions Workflows
2+
3+
This directory contains GitHub Actions workflows for the create-net project.
4+
5+
## Workflows
6+
7+
### CI (`ci.yml`)
8+
9+
Runs on every push to `main` and on all pull requests.
10+
11+
**What it does:**
12+
- Tests the package on multiple Node.js versions (14, 16, 18, 20)
13+
- Runs the test suite (`npm test`)
14+
- Verifies the CLI script is executable
15+
16+
### Publish to npm (`publish.yml`)
17+
18+
Runs automatically when a new GitHub release is created.
19+
20+
**What it does:**
21+
- Installs dependencies
22+
- Runs tests to ensure quality
23+
- Publishes the package to npm
24+
25+
## Publishing to npm
26+
27+
To publish a new version:
28+
29+
1. Update the version in `package.json`:
30+
```bash
31+
npm version patch # for bug fixes
32+
npm version minor # for new features
33+
npm version major # for breaking changes
34+
```
35+
36+
2. Push the changes and tags:
37+
```bash
38+
git push && git push --tags
39+
```
40+
41+
3. Create a GitHub release:
42+
- Go to https://github.com/ServiceStack/create-net/releases/new
43+
- Select the version tag you just pushed
44+
- Add release notes describing the changes
45+
- Click "Publish release"
46+
47+
4. The `publish.yml` workflow will automatically:
48+
- Run tests
49+
- Publish to npm if tests pass
50+
51+
## Required Secrets
52+
53+
For the publish workflow to work, you need to add an `NPM_TOKEN` secret to your GitHub repository:
54+
55+
1. Generate an npm token:
56+
- Log in to https://www.npmjs.com
57+
- Go to Account Settings → Access Tokens
58+
- Generate a new "Automation" token
59+
60+
2. Add the token to GitHub:
61+
- Go to repository Settings → Secrets and variables → Actions
62+
- Click "New repository secret"
63+
- Name: `NPM_TOKEN`
64+
- Value: Your npm token
65+
- Click "Add secret"
66+
67+
## Manual Publishing
68+
69+
If you prefer to publish manually:
70+
71+
```bash
72+
npm login
73+
npm publish
74+
```

.github/workflows/ci.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
node-version: [14, 16, 18, 20]
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Setup Node.js ${{ matrix.node-version }}
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: ${{ matrix.node-version }}
25+
26+
- name: Install dependencies
27+
run: npm install
28+
29+
- name: Run tests
30+
run: npm test
31+
32+
- name: Verify bin script is executable
33+
run: |
34+
chmod +x bin/create-net.js
35+
node bin/create-net.js 2>&1 | grep -q "Usage: npx create-net"

.github/workflows/publish.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Publish to npm
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
publish:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v4
14+
15+
- name: Setup Node.js
16+
uses: actions/setup-node@v4
17+
with:
18+
node-version: '18'
19+
registry-url: 'https://registry.npmjs.org'
20+
21+
- name: Install dependencies
22+
run: npm install
23+
24+
- name: Run tests
25+
run: npm test
26+
27+
- name: Publish to npm
28+
run: npm publish
29+
env:
30+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

README.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,36 @@ This creates test projects in `test-manual/` for manual verification. Clean up w
8888

8989
## Publishing
9090

91-
To publish this package to npm:
91+
### Automated Publishing (Recommended)
92+
93+
The package is automatically published to npm when a new GitHub release is created:
94+
95+
1. Update the version:
96+
```bash
97+
npm version patch # for bug fixes (1.0.0 → 1.0.1)
98+
npm version minor # for new features (1.0.0 → 1.1.0)
99+
npm version major # for breaking changes (1.0.0 → 2.0.0)
100+
```
101+
102+
2. Push changes and tags:
103+
```bash
104+
git push && git push --tags
105+
```
106+
107+
3. Create a GitHub release at https://github.com/ServiceStack/create-net/releases/new
108+
- The GitHub Action will automatically run tests and publish to npm
109+
110+
### Manual Publishing
111+
112+
To publish manually:
92113

93114
```bash
115+
npm login
94116
npm publish
95117
```
96118

119+
**Note:** You need to configure the `NPM_TOKEN` secret in GitHub repository settings for automated publishing. See [`.github/workflows/README.md`](.github/workflows/README.md) for details.
120+
97121
## License
98122

99123
MIT

package.json

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,28 @@
22
"name": "create-net",
33
"version": "1.0.0",
44
"description": "Create .NET and other projects from NetCoreTemplates GitHub repositories",
5-
"main": "index.js",
65
"bin": {
76
"create-net": "./bin/create-net.js"
87
},
98
"scripts": {
10-
"test": "echo \"Error: no test specified\" && exit 1"
9+
"test": "./test.sh"
1110
},
1211
"keywords": [
1312
"create",
1413
"template",
1514
"project",
1615
"NetCoreTemplates",
17-
"scaffold"
16+
"scaffold",
17+
"cli",
18+
"generator"
1819
],
19-
"author": "",
20+
"author": "ServiceStack",
2021
"license": "MIT",
22+
"repository": {
23+
"type": "git",
24+
"url": "https://github.com/ServiceStack/create-net"
25+
},
26+
"private": false,
2127
"dependencies": {
2228
"adm-zip": "^0.5.10"
2329
},

0 commit comments

Comments
 (0)