Skip to content

Commit 1cb92a2

Browse files
Merge pull request #15 from patternfly/ci-npm-updates
Added code for npm publishing via semantic release.
2 parents 4cd82e1 + 9b200e7 commit 1cb92a2

File tree

10 files changed

+9279
-2306
lines changed

10 files changed

+9279
-2306
lines changed

.github/workflows/build.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
branches: [main, master]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- uses: actions/setup-node@v4
16+
with:
17+
node-version: '20'
18+
cache: 'npm'
19+
20+
- run: npm ci
21+
- run: npm run build

.github/workflows/lint.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Lint
2+
3+
on:
4+
workflow_run:
5+
workflows: [Build]
6+
types: [completed]
7+
branches: [main, master]
8+
9+
jobs:
10+
lint:
11+
runs-on: ubuntu-latest
12+
if: github.event.workflow_run.conclusion == 'success'
13+
steps:
14+
- uses: actions/checkout@v4
15+
with:
16+
ref: ${{ github.event.workflow_run.head_sha }}
17+
18+
- uses: actions/setup-node@v4
19+
with:
20+
node-version: '20'
21+
cache: 'npm'
22+
23+
- run: npm ci
24+
- run: npm run lint

.github/workflows/release.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
10+
issues: write
11+
pull-requests: write
12+
13+
jobs:
14+
release:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
persist-credentials: false
22+
23+
- name: Setup Node.js
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: "20"
27+
cache: "npm"
28+
29+
- name: Install dependencies
30+
run: npm ci
31+
32+
- name: Build
33+
run: npm run build
34+
35+
- name: Run tests
36+
run: npm test
37+
38+
- name: Release
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
42+
run: npm run semantic-release

.github/workflows/test.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Test
2+
3+
on:
4+
workflow_run:
5+
workflows: [Build]
6+
types: [completed]
7+
branches: [main, master]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
if: github.event.workflow_run.conclusion == 'success'
13+
steps:
14+
- uses: actions/checkout@v4
15+
with:
16+
ref: ${{ github.event.workflow_run.head_sha }}
17+
18+
- uses: actions/setup-node@v4
19+
with:
20+
node-version: '20'
21+
cache: 'npm'
22+
23+
- run: npm ci
24+
- run: npm test

.releaserc.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"branches": ["main"],
3+
"analyzeCommits": "angular",
4+
"plugins": [
5+
[
6+
"@semantic-release/commit-analyzer",
7+
{
8+
"preset": "angular",
9+
"parserOpts" : {
10+
"noteKeywords": [ "BREAKING-CHANGE" ]
11+
}
12+
}
13+
],
14+
"@semantic-release/release-notes-generator",
15+
"@semantic-release/npm",
16+
"@semantic-release/github"
17+
],
18+
"dryRun": "true"
19+
}

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,12 @@ After building the cli you can install the cli globally by running the following
9999
npm install -g
100100
```
101101

102-
After that you can now execute the cli via ```patternfly-cli``` command in the terminal. We are currently in the process of moving this to npmjs once we this ready for v 1.0.0
102+
After that you can now execute the cli via ```patternfly-cli``` command in the terminal.
103+
104+
### Releasing
105+
106+
This project uses [semantic-release](https://semantic-release.gitbook.io/) to automate versioning and releases based on [Conventional Commits](https://www.conventionalcommits.org/).
107+
108+
- **CI**: Pushing to `main` runs the release workflow. If there are commits that warrant a release (e.g. `feat:`, `fix:`, `BREAKING CHANGE:`), it will create a GitHub release, update `CHANGELOG.md`, and bump the version in `package.json`.
109+
- **Local dry run**: `npx semantic-release --dry-run` (no push or publish).
110+
- **npm publish**: By default only GitHub releases are created. To publish to npm, set the `NPM_TOKEN` secret in the repo and set `"npmPublish": true` for the `@semantic-release/npm` plugin in `.releaserc.json`.

eslint.config.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import eslint from '@eslint/js';
2+
import tseslint from 'typescript-eslint';
3+
4+
export default tseslint.config(
5+
eslint.configs.recommended,
6+
...tseslint.configs.recommended,
7+
{
8+
languageOptions: {
9+
parserOptions: {
10+
projectService: true,
11+
tsconfigRootDir: import.meta.dirname,
12+
},
13+
},
14+
},
15+
{
16+
files: ['**/__tests__/**/*.test.ts'],
17+
extends: [tseslint.configs.disableTypeChecked],
18+
}
19+
);

0 commit comments

Comments
 (0)