Skip to content

Commit 097f297

Browse files
authored
chore: Setup automated publishing with changesets (#2)
- Add changesets CLI for version management - Configure GitHub Actions workflow for automated publishing - Publish to npm (primary) and GitHub Packages (secondary) - Add npm scripts: changeset, version, release - Configure publishConfig for public access Workflow: - Runs on push to main with changesets - Creates "Version Packages" PR automatically - Publishes to npm first (fail-fast) - Then publishes to GitHub Packages if npm succeeds
1 parent 85e3d35 commit 097f297

File tree

5 files changed

+1313
-2
lines changed

5 files changed

+1313
-2
lines changed

.changeset/README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Changesets
2+
3+
Hello! 👋
4+
5+
This folder contains "changeset" files - each one describes a change to the package.
6+
7+
## Quick Start
8+
9+
### Adding a changeset
10+
11+
When you make a change that should trigger a release:
12+
13+
```bash
14+
npm run changeset
15+
```
16+
17+
Follow the prompts:
18+
1. **Select change type**: patch, minor, or major
19+
2. **Write a summary**: Describe what changed
20+
21+
### What happens next?
22+
23+
1. Commit the changeset file
24+
2. Push to `main` branch
25+
3. GitHub Action creates a "Version Packages" PR
26+
4. Merge that PR to publish
27+
28+
## Change Types
29+
30+
- **patch** (1.0.0 → 1.0.1): Bug fixes
31+
- **minor** (1.0.0 → 1.1.0): New features
32+
- **major** (1.0.0 → 2.0.0): Breaking changes
33+
34+
## Example
35+
36+
```bash
37+
# Make your changes
38+
git add .
39+
git commit -m "fix: timezone validation"
40+
41+
# Add changeset
42+
npm run changeset
43+
# → Select: patch
44+
# → Summary: "Fix timezone offset range to support UTC-12 to UTC+14"
45+
46+
# Commit and push
47+
git add .changeset
48+
git commit -m "chore: add changeset"
49+
git push
50+
```
51+
52+
## Learn More
53+
54+
- [Changesets Documentation](https://github.com/changesets/changesets)
55+
- See `PUBLISHING.md` for full workflow details

.changeset/config.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/config@3.1.2/schema.json",
3+
"changelog": "@changesets/cli/changelog",
4+
"commit": false,
5+
"fixed": [],
6+
"linked": [],
7+
"access": "public",
8+
"baseBranch": "main",
9+
"updateInternalDependencies": "patch",
10+
"ignore": []
11+
}

.github/workflows/publish.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Publish Package
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
release:
10+
name: Release
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
packages: write
15+
pull-requests: write
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Setup Node.js
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: '22.x'
27+
cache: 'npm'
28+
29+
- name: Install dependencies
30+
run: npm ci
31+
32+
- name: Run tests
33+
run: npm test
34+
35+
- name: Build
36+
run: npm run build
37+
38+
# Configure npm registry for publishing
39+
- name: Setup Node.js for npm
40+
uses: actions/setup-node@v4
41+
with:
42+
node-version: '22.x'
43+
registry-url: 'https://registry.npmjs.org'
44+
45+
- name: Create Release Pull Request or Publish to npm
46+
id: changesets
47+
uses: changesets/action@v1
48+
with:
49+
publish: npm run release
50+
title: 'chore: version packages'
51+
commit: 'chore: version packages'
52+
env:
53+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
55+
56+
# Only publish to GitHub Packages if npm publish succeeded
57+
- name: Setup Node.js for GitHub Packages
58+
if: steps.changesets.outputs.published == 'true'
59+
uses: actions/setup-node@v4
60+
with:
61+
node-version: '22.x'
62+
registry-url: 'https://npm.pkg.github.com'
63+
scope: '@taskade'
64+
65+
- name: Publish to GitHub Packages
66+
if: steps.changesets.outputs.published == 'true'
67+
run: npm publish
68+
env:
69+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)