Skip to content

Commit 57e4dca

Browse files
committed
Workflow and build update
1 parent c839e0f commit 57e4dca

3 files changed

Lines changed: 140 additions & 0 deletions

File tree

.github/workflows/ci.yml

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

.github/workflows/publish.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Publish Package
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: read
10+
packages: write
11+
12+
jobs:
13+
publish:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
20+
- name: Setup Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: '22'
24+
registry-url: 'https://npm.pkg.github.com'
25+
cache: 'npm'
26+
27+
- name: Extract version from tag
28+
id: version
29+
run: echo "VERSION=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
30+
31+
- name: Set package version from tag
32+
run: npm version "${{ steps.version.outputs.VERSION }}" --no-git-tag-version
33+
34+
- name: Install dependencies
35+
run: npm ci
36+
37+
- name: Lint
38+
run: npm run lint
39+
40+
- name: Run tests
41+
run: npm test
42+
43+
- name: Build
44+
run: npm run build
45+
46+
- name: Publish to GitHub Packages
47+
run: npm publish
48+
env:
49+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+

README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,59 @@ export type { ButtonProps } from './components/Button';
144144
| `npm run format` | Format code with Prettier |
145145
| `npm run format:check` | Check formatting without writing |
146146

147+
## CI/CD
148+
149+
This project uses GitHub Actions for continuous integration and publishing.
150+
151+
### CI (`.github/workflows/ci.yml`)
152+
153+
Runs automatically on every **push to `main`** and on **pull requests** targeting `main`. It runs lint, tests, and build to catch issues early.
154+
155+
### Publishing (`.github/workflows/publish.yml`)
156+
157+
Runs when you push a **version tag** (e.g. `v0.2.0`). The version in `package.json` is set automatically from the tag name — no need to update it manually. The package is published to **GitHub Packages**.
158+
159+
To publish a new version:
160+
161+
```bash
162+
git tag v0.2.0
163+
git push origin v0.2.0
164+
```
165+
166+
## Installing in a Consuming Project
167+
168+
Since this package is hosted on GitHub Packages, the consuming project needs a one-time setup.
169+
170+
### 1. Create a GitHub Personal Access Token
171+
172+
Go to [GitHub → Settings → Developer settings → Personal access tokens](https://github.com/settings/tokens) and create a **classic** token with the **`read:packages`** scope.
173+
174+
### 2. Add a `.npmrc` to the consuming project root
175+
176+
```ini
177+
@pigna:registry=https://npm.pkg.github.com
178+
//npm.pkg.github.com/:_authToken=${NPM_TOKEN}
179+
```
180+
181+
> **Do not commit a real token.** The `.npmrc` references an environment variable (`NPM_TOKEN`).
182+
183+
### 3. Set the token
184+
185+
- **Locally:** export the token in your shell before running `npm install`:
186+
```bash
187+
export NPM_TOKEN=ghp_your_token_here # macOS/Linux
188+
$env:NPM_TOKEN="ghp_your_token_here" # PowerShell
189+
```
190+
Alternatively, add the token to your **user-level** `~/.npmrc` so it applies globally without polluting the project.
191+
192+
- **In CI:** add `NPM_TOKEN` as a **repository secret** in the consuming project's GitHub settings. Then pass it as an environment variable in your workflow.
193+
194+
### 4. Install the package
195+
196+
```bash
197+
npm install @pigna/component-library
198+
```
199+
147200
## Other tools
148201
- ```npx skills add pbakaus/impeccable``` - Styling tool by **pbakaus/impeccable** https://impeccable.style/
149202

0 commit comments

Comments
 (0)