Skip to content

Commit 328dbf9

Browse files
authored
feat: Publish to pf npm
feat: Publish to pf npm
2 parents 1841064 + e022294 commit 328dbf9

File tree

6 files changed

+253
-33
lines changed

6 files changed

+253
-33
lines changed

.github/workflows/README.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# GitHub Actions Workflows
2+
3+
This directory contains the CI/CD workflows for automatically releasing `@patternfly/context-for-ai` to NPM.
4+
5+
## Workflows
6+
7+
### build-lint-test.yml
8+
Runs on pull requests and pushes to main. This workflow:
9+
- Type checks the code
10+
- Runs ESLint
11+
- Runs Jest tests
12+
- Builds the distribution files
13+
14+
### release.yml
15+
Runs on pushes to the `main` branch. This workflow:
16+
- Calls the build-lint-test workflow first
17+
- Uses semantic-release to automatically version and publish to NPM
18+
- Creates GitHub releases with changelogs
19+
20+
## Required Secrets
21+
22+
You need to set up the following secrets in your GitHub repository:
23+
24+
### NPM_TOKEN
25+
1. Log in to npm and go to https://www.npmjs.com/settings/YOUR_USERNAME/tokens
26+
2. Click "Generate New Token" → "Classic Token"
27+
3. Select "Automation" type
28+
4. Copy the token
29+
5. In your GitHub repo, go to Settings → Secrets and variables → Actions
30+
6. Click "New repository secret"
31+
7. Name: `NPM_TOKEN`
32+
8. Value: Your npm token
33+
9. Click "Add secret"
34+
35+
### GITHUB_TOKEN
36+
This is automatically provided by GitHub Actions, no setup needed.
37+
38+
## Semantic Release
39+
40+
The release process uses [semantic-release](https://semantic-release.gitbook.io/) which automates version management and package publishing based on commit messages.
41+
42+
### Commit Message Format
43+
44+
Use conventional commits to trigger releases:
45+
46+
- `fix: ...` → Patch release (1.0.0 → 1.0.1)
47+
- `feat: ...` → Minor release (1.0.0 → 1.1.0)
48+
- `feat!: ...` or `BREAKING CHANGE:` in body → Major release (1.0.0 → 2.0.0)
49+
50+
Examples:
51+
```
52+
fix: resolve button styling issue
53+
feat: add new Card component
54+
feat!: rename all component props (breaking change)
55+
```
56+
57+
### First Release
58+
59+
For your first release, you may want to run:
60+
```bash
61+
npm version 1.0.0
62+
git add package.json
63+
git commit -m "chore: initial release setup"
64+
git push
65+
```
66+
67+
Or let semantic-release handle it automatically based on commits.
68+
69+
## Testing Locally
70+
71+
Before pushing to main, you can test the workflow:
72+
73+
```bash
74+
# Run all checks locally
75+
npm run type-check
76+
npm run lint
77+
npm test
78+
npm run build
79+
```
80+
81+
## Troubleshooting
82+
83+
### Release not triggering
84+
- Ensure your commit messages follow the conventional commit format
85+
- Check the Actions tab in GitHub for error messages
86+
- Verify NPM_TOKEN is set correctly
87+
88+
### NPM publish fails
89+
- Verify the package name `@patternfly/context-for-ai` is available/you have access
90+
- Ensure NPM_TOKEN has publish permissions
91+
- Check if you need to be added to the @patternfly organization on npm
92+
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Build, Lint, and Test
2+
3+
on:
4+
workflow_call:
5+
pull_request:
6+
branches:
7+
- main
8+
push:
9+
branches:
10+
- main
11+
12+
jobs:
13+
build-lint-test:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- uses: actions/setup-node@v4
20+
with:
21+
node-version: '20'
22+
23+
- name: Cache node modules
24+
uses: actions/cache@v4
25+
id: npm-cache
26+
with:
27+
path: node_modules
28+
key: ${{ runner.os }}-node-20-${{ hashFiles('package-lock.json') }}
29+
restore-keys: |
30+
${{ runner.os }}-node-20-
31+
32+
- name: Install dependencies
33+
if: steps.npm-cache.outputs.cache-hit != 'true'
34+
run: npm ci
35+
36+
- name: Run type check
37+
run: npm run type-check
38+
39+
- name: Run linter
40+
run: npm run lint
41+
42+
- name: Run tests
43+
run: npm test
44+
45+
- name: Build
46+
run: npm run build
47+

.github/workflows/release.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
call-build-lint-test-workflow:
10+
uses: ./.github/workflows/build-lint-test.yml
11+
12+
deploy:
13+
runs-on: ubuntu-latest
14+
needs: [call-build-lint-test-workflow]
15+
env:
16+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
17+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
persist-credentials: false
24+
25+
- uses: actions/setup-node@v4
26+
with:
27+
node-version: '20'
28+
registry-url: 'https://registry.npmjs.org'
29+
30+
- name: Cache node modules
31+
uses: actions/cache@v4
32+
id: npm-cache
33+
with:
34+
path: node_modules
35+
key: ${{ runner.os }}-node-20-${{ hashFiles('package-lock.json') }}
36+
restore-keys: |
37+
${{ runner.os }}-node-20-
38+
39+
- name: Install dependencies
40+
if: steps.npm-cache.outputs.cache-hit != 'true'
41+
run: npm ci
42+
43+
- name: Cache dist
44+
uses: actions/cache@v4
45+
id: dist
46+
with:
47+
path: dist
48+
key: ${{ runner.os }}-dist-${{ hashFiles('package-lock.json', 'package.json', 'src/**/*', 'rollup.config.js', 'tsconfig.json') }}
49+
50+
- name: Build dist
51+
run: npm run build
52+
if: steps.dist.outputs.cache-hit != 'true'
53+
54+
- name: Release to NPM
55+
env:
56+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
58+
run: npx semantic-release
59+

.releaserc.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"branches": ["main"],
3+
"plugins": [
4+
"@semantic-release/commit-analyzer",
5+
"@semantic-release/release-notes-generator",
6+
"@semantic-release/npm",
7+
[
8+
"@semantic-release/git",
9+
{
10+
"assets": ["package.json"],
11+
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
12+
}
13+
],
14+
"@semantic-release/github"
15+
]
16+
}
17+

README.md

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
> **⚠️ Important**: This is a **codemod tool only**. You do NOT need to import or use any library components. Simply install the package and run the codemod to transform your existing PatternFly components. The library code in this repository is for reference/development purposes only.
44
5-
**📦 Install from npm**: `npm install -D @kelseamann/semantic-ui-layer`
6-
**🔗 Package**: [@kelseamann/semantic-ui-layer on npm](https://www.npmjs.com/package/@kelseamann/semantic-ui-layer)
5+
**📦 Install from npm**: `npm install -D @patternfly/context-for-ai`
6+
**🔗 Package**: [@patternfly/context-for-ai on npm](https://www.npmjs.com/package/@patternfly/context-for-ai)
77

88
A codemod tool that automatically adds standardized semantic `data-*` attributes to **all PatternFly components** in your codebase, making them AI-friendly and easier for AI tools to understand.
99

@@ -38,10 +38,10 @@ This tool transforms your existing PatternFly components by adding semantic meta
3838
Install from npm as a dev dependency (recommended):
3939

4040
```bash
41-
npm install -D @kelseamann/semantic-ui-layer
41+
npm install -D @patternfly/context-for-ai
4242
```
4343

44-
**📦 Package**: [@kelseamann/semantic-ui-layer on npm](https://www.npmjs.com/package/@kelseamann/semantic-ui-layer)
44+
**📦 Package**: [@patternfly/context-for-ai on npm](https://www.npmjs.com/package/@patternfly/context-for-ai)
4545

4646
> **Note**:
4747
> - Installed as a dev dependency (`-D`) since it's only needed during development
@@ -55,23 +55,21 @@ You have two options:
5555

5656
**Option A: Using npx with jscodeshift (recommended)**
5757
```bash
58-
npx jscodeshift -t node_modules/@kelseamann/semantic-ui-layer/codemod/transform.js --extensions=ts,tsx,js,jsx --parser=tsx src/
58+
npx jscodeshift -t node_modules/@patternfly/context-for-ai/codemod/transform.js --extensions=ts,tsx,js,jsx --parser=tsx src/
5959
```
6060

6161
**Option B: Using the provided script**
6262
```bash
63-
./node_modules/@kelseamann/semantic-ui-layer/codemod/add-semantic-attributes.sh src/
63+
./node_modules/@patternfly/context-for-ai/codemod/add-semantic-attributes.sh src/
6464
```
6565

66-
> **Note**: Option A uses `npx` which automatically downloads and runs jscodeshift without requiring a global install!
67-
6866
### Setup on a New Computer
6967

7068
If you're setting up the codemod on a new computer:
7169

7270
1. **Install Node.js** (if not already installed)
73-
2. **Install @kelseamann/semantic-ui-layer** in your project: `npm install -D @kelseamann/semantic-ui-layer`
74-
3. **Run the codemod** using `npx jscodeshift` (see options above)
71+
2. **Install @patternfly/context-for-ai** in your project: `npm install -D @patternfly/context-for-ai`
72+
3. **Run the codemod** using npx (recommended) or the bash script above
7573

7674
The codemod is a standalone tool - you don't need to import or use any library components. It simply transforms your existing PatternFly components by adding semantic attributes.
7775

@@ -97,22 +95,23 @@ Into:
9795
data-role="card"
9896
data-purpose="clickable"
9997
data-variant="default"
100-
data-context="default"
98+
data-context="page"
10199
data-state="active"
102100
>
103101
<CardBody
104102
data-role="card-body"
105103
data-purpose="display"
106104
data-variant="default"
107-
data-context="default"
108-
data-state="default"
105+
data-context="page"
106+
data-state="active"
109107
>
110108
<Button
111109
variant="danger"
112110
data-role="button"
113111
data-purpose="action"
114112
data-variant="danger"
115-
data-context="default"
113+
data-context="page"
114+
data-action-type="destructive"
116115
data-state="active"
117116
>
118117
Cancel
@@ -163,10 +162,10 @@ Every PatternFly component gets the same 7 attributes that appear on rendered DO
163162
Install the package from npm as a dev dependency:
164163

165164
```bash
166-
npm install -D @kelseamann/semantic-ui-layer
165+
npm install -D @patternfly/context-for-ai
167166
```
168167

169-
**📦 Package**: [@kelseamann/semantic-ui-layer on npm](https://www.npmjs.com/package/@kelseamann/semantic-ui-layer)
168+
**📦 Package**: [@patternfly/context-for-ai on npm](https://www.npmjs.com/package/@patternfly/context-for-ai)
170169

171170
**Note**:
172171
- This installs the codemod tool as a dev dependency since it's only needed during development
@@ -182,15 +181,15 @@ npm install -D @kelseamann/semantic-ui-layer
182181
The codemod is distributed as an npm package. To check if you have the latest version:
183182

184183
```bash
185-
npm outdated @kelseamann/semantic-ui-layer
184+
npm outdated @patternfly/context-for-ai
186185
```
187186

188187
### Updating the Codemod
189188

190189
```bash
191-
npm update @kelseamann/semantic-ui-layer
192-
# or for latest version
193-
npm install -D @kelseamann/semantic-ui-layer@latest
190+
npm update @patternfly/context-for-ai
191+
# or
192+
npm install -D @patternfly/context-for-ai@latest
194193
```
195194

196195
### When to Re-run the Codemod
@@ -225,32 +224,32 @@ Check the commit history or GitHub releases to see what improvements were made i
225224
### Transform Entire Directory
226225

227226
```bash
228-
npx jscodeshift -t node_modules/@kelseamann/semantic-ui-layer/codemod/transform.js --extensions=ts,tsx,js,jsx --parser=tsx src/
227+
jscodeshift -t node_modules/@patternfly/context-for-ai/codemod/transform.js --extensions=ts,tsx,js,jsx --parser=tsx src/
229228
```
230229

231230
### Transform Specific File
232231

233232
```bash
234-
npx jscodeshift -t node_modules/@kelseamann/semantic-ui-layer/codemod/transform.js src/components/MyComponent.tsx
233+
jscodeshift -t node_modules/@patternfly/context-for-ai/codemod/transform.js src/components/MyComponent.tsx
235234
```
236235

237236
### Preview Changes (Dry Run)
238237

239238
```bash
240-
npx jscodeshift -t node_modules/@kelseamann/semantic-ui-layer/codemod/transform.js --dry src/
239+
jscodeshift -t node_modules/@patternfly/context-for-ai/codemod/transform.js --dry src/
241240
```
242241

243242
### Using the Bash Script
244243

245244
```bash
246245
# Transform all files in src/
247-
./node_modules/@kelseamann/semantic-ui-layer/codemod/add-semantic-attributes.sh src/
246+
./node_modules/@patternfly/context-for-ai/codemod/add-semantic-attributes.sh src/
248247

249248
# Transform a specific file
250-
./node_modules/@kelseamann/semantic-ui-layer/codemod/add-semantic-attributes.sh src/components/MyComponent.tsx
249+
./node_modules/@patternfly/context-for-ai/codemod/add-semantic-attributes.sh src/components/MyComponent.tsx
251250

252251
# Transform current directory
253-
./node_modules/semantic-ui-layer/codemod/add-semantic-attributes.sh
252+
./node_modules/@patternfly/context-for-ai/codemod/add-semantic-attributes.sh
254253
```
255254

256255
## Supported PatternFly Packages
@@ -587,8 +586,8 @@ If you're using this package, you should only use the codemod tool - ignore any
587586

588587
```bash
589588
# Clone the repository
590-
git clone https://github.com/kelseamann/semantic-UI.git
591-
cd semantic-ui-layer
589+
git clone https://github.com/patternfly/context-for-ai.git
590+
cd context-for-ai
592591

593592
# Install dependencies
594593
npm install

0 commit comments

Comments
 (0)