Skip to content

Commit 829e895

Browse files
committed
init: scaffold @scope3/observability-js package
0 parents  commit 829e895

12 files changed

Lines changed: 2055 additions & 0 deletions

File tree

.github/workflows/check.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: check
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
check:
14+
name: Build, Typecheck & Lint
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Setup Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: 24.x
24+
cache: npm
25+
26+
- name: Install dependencies
27+
run: npm ci
28+
29+
- name: Build
30+
run: npm run build
31+
32+
- name: Typecheck
33+
run: npm run typecheck
34+
35+
- name: Lint
36+
run: npm run lint

.github/workflows/release.yml

Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
name: release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-main
10+
cancel-in-progress: false
11+
12+
jobs:
13+
release:
14+
name: Release
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: write
18+
id-token: write
19+
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
fetch-tags: true
26+
27+
- name: Setup Node.js
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version: 24.x
31+
cache: npm
32+
33+
- name: Install dependencies
34+
run: npm ci
35+
36+
- name: Get package.json version
37+
id: pkg_version
38+
run: |
39+
VERSION=$(node -p "require('./package.json').version")
40+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
41+
echo "tag=v${VERSION}" >> $GITHUB_OUTPUT
42+
echo "Package version: ${VERSION}"
43+
44+
- name: Get latest git tag
45+
id: latest_tag
46+
run: |
47+
git fetch --tags origin
48+
LATEST_TAG=$(git tag --sort=-version:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+' | head -1 || echo "")
49+
echo "tag=${LATEST_TAG}" >> $GITHUB_OUTPUT
50+
echo "Latest tag: ${LATEST_TAG:-none}"
51+
52+
- name: Check if release is needed
53+
id: should_release
54+
run: |
55+
PKG_VERSION="${{ steps.pkg_version.outputs.version }}"
56+
LATEST_TAG="${{ steps.latest_tag.outputs.tag }}"
57+
58+
if [ -z "$LATEST_TAG" ]; then
59+
echo "No existing tags found, proceeding with first release"
60+
echo "needed=true" >> $GITHUB_OUTPUT
61+
exit 0
62+
fi
63+
64+
LATEST_VERSION="${LATEST_TAG#v}"
65+
66+
IS_GREATER=$(node -e "
67+
const { gt, valid } = require('semver');
68+
const pkg = '${PKG_VERSION}';
69+
const latest = '${LATEST_VERSION}';
70+
if (!valid(pkg) || !valid(latest)) {
71+
console.error('Invalid semver: pkg=' + pkg + ' latest=' + latest);
72+
process.exit(1);
73+
}
74+
console.log(gt(pkg, latest) ? 'true' : 'false');
75+
")
76+
77+
echo "needed=${IS_GREATER}" >> $GITHUB_OUTPUT
78+
79+
if [ "$IS_GREATER" = "true" ]; then
80+
echo "Version ${PKG_VERSION} > ${LATEST_VERSION}, release needed"
81+
else
82+
echo "Version ${PKG_VERSION} <= ${LATEST_VERSION}, skipping release"
83+
fi
84+
85+
- name: Validate version format
86+
if: steps.should_release.outputs.needed == 'true'
87+
env:
88+
TAG_NAME: ${{ steps.pkg_version.outputs.tag }}
89+
run: |
90+
if ! printf "%s\n" "$TAG_NAME" | grep -qP '^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-(alpha|beta|rc)\.(0|[1-9][0-9]*))?$'; then
91+
printf '[ERROR]: Invalid version tag format (%s)\n' "$TAG_NAME"
92+
exit 1
93+
fi
94+
echo "Version tag format is valid: $TAG_NAME"
95+
96+
- name: Determine if prerelease
97+
if: steps.should_release.outputs.needed == 'true'
98+
id: prerelease
99+
env:
100+
TAG_NAME: ${{ steps.pkg_version.outputs.tag }}
101+
run: |
102+
if printf "%s\n" "$TAG_NAME" | grep -qP '^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$'; then
103+
echo "value=false" >> $GITHUB_OUTPUT
104+
else
105+
echo "value=true" >> $GITHUB_OUTPUT
106+
fi
107+
108+
- name: Collect changelog
109+
if: steps.should_release.outputs.needed == 'true'
110+
id: changelog
111+
run: |
112+
LATEST_TAG="${{ steps.latest_tag.outputs.tag }}"
113+
114+
if [ -z "$LATEST_TAG" ]; then
115+
git log HEAD --pretty=format:"- %s" --no-merges > /tmp/commits.txt
116+
else
117+
git log ${LATEST_TAG}..HEAD --pretty=format:"- %s" --no-merges > /tmp/commits.txt
118+
fi
119+
120+
COMMITS_B64=$(base64 -w 0 /tmp/commits.txt)
121+
echo "commits_b64=${COMMITS_B64}" >> $GITHUB_OUTPUT
122+
123+
- name: Configure git
124+
if: steps.should_release.outputs.needed == 'true'
125+
run: |
126+
git config --local user.email "action@github.com"
127+
git config --local user.name "GitHub Action"
128+
129+
- name: Create and push tag
130+
if: steps.should_release.outputs.needed == 'true'
131+
run: |
132+
TAG="${{ steps.pkg_version.outputs.tag }}"
133+
COMMIT_MESSAGES=$(echo "${{ steps.changelog.outputs.commits_b64 }}" | base64 -d)
134+
TAG_MESSAGE=$(printf "Release %s\n\nChanges in this release:\n%s" "${TAG}" "${COMMIT_MESSAGES}")
135+
136+
git tag -a "${TAG}" -m "${TAG_MESSAGE}"
137+
git push origin "${TAG}"
138+
139+
- name: Create GitHub Release
140+
if: steps.should_release.outputs.needed == 'true'
141+
env:
142+
GH_TOKEN: ${{ github.token }}
143+
COMMITS_B64: ${{ steps.changelog.outputs.commits_b64 }}
144+
run: |
145+
TAG="${{ steps.pkg_version.outputs.tag }}"
146+
COMMIT_MESSAGES=$(echo "$COMMITS_B64" | base64 -d)
147+
RELEASE_BODY=$(printf "## Changes in this release:\n\n%s" "${COMMIT_MESSAGES}")
148+
149+
PRERELEASE_FLAG=""
150+
if [ "${{ steps.prerelease.outputs.value }}" = "true" ]; then
151+
PRERELEASE_FLAG="--prerelease"
152+
fi
153+
154+
gh release create "${TAG}" \
155+
--title "${TAG}" \
156+
--notes "${RELEASE_BODY}" \
157+
${PRERELEASE_FLAG}
158+
159+
- name: Setup Node.js for publishing
160+
if: steps.should_release.outputs.needed == 'true'
161+
uses: actions/setup-node@v4
162+
with:
163+
node-version: 24.x
164+
registry-url: https://registry.npmjs.org
165+
166+
- name: Build package
167+
if: steps.should_release.outputs.needed == 'true'
168+
run: npm run build
169+
170+
- name: Publish to npm
171+
if: steps.should_release.outputs.needed == 'true'
172+
env:
173+
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
174+
run: |
175+
NPM_TAG="latest"
176+
if [ "${{ steps.prerelease.outputs.value }}" = "true" ]; then
177+
NPM_TAG="next"
178+
fi
179+
180+
npm publish --ignore-scripts --access public --tag "$NPM_TAG"
181+
182+
- name: Summary
183+
if: steps.should_release.outputs.needed == 'true'
184+
run: |
185+
echo "## Release Summary" >> $GITHUB_STEP_SUMMARY
186+
echo "- **Version**: ${{ steps.pkg_version.outputs.tag }}" >> $GITHUB_STEP_SUMMARY
187+
echo "- **Prerelease**: ${{ steps.prerelease.outputs.value }}" >> $GITHUB_STEP_SUMMARY
188+
echo "- **npm tag**: ${{ steps.prerelease.outputs.value == 'true' && 'next' || 'latest' }}" >> $GITHUB_STEP_SUMMARY
189+
190+
- name: No release needed
191+
if: steps.should_release.outputs.needed != 'true'
192+
run: |
193+
echo "## No Release" >> $GITHUB_STEP_SUMMARY
194+
echo "- **Package version**: ${{ steps.pkg_version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
195+
echo "- **Latest tag**: ${{ steps.latest_tag.outputs.tag || 'none' }}" >> $GITHUB_STEP_SUMMARY
196+
echo "- **Reason**: Version not greater than latest tag, skipping release" >> $GITHUB_STEP_SUMMARY

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules/
2+
dist/
3+
coverage/
4+
.env
5+
.idea/
6+
.DS_Store
7+
*.tsbuildinfo

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
24

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 Scope3 Data, Inc.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# @scope3/observability-js
2+
3+
Observability utilities for Node.js applications, published by [Scope3](https://scope3.com).
4+
5+
## Installation
6+
7+
```sh
8+
npm install @scope3/observability-js
9+
```
10+
11+
## Usage
12+
13+
```ts
14+
import {} from '@scope3/observability-js'
15+
```
16+
17+
> More documentation will be added as the package evolves.
18+
19+
## Contributing
20+
21+
This package is open source under the [MIT License](./LICENSE). Contributions are welcome via pull request against the `main` branch.
22+
23+
Before submitting a PR, make sure the following pass locally:
24+
25+
```sh
26+
npm run build
27+
npm run typecheck
28+
npm run lint
29+
```
30+
31+
### Releasing
32+
33+
Releases are automated. When a pull request is merged to `main` with a bumped version in `package.json`, the release workflow will:
34+
35+
1. Compare the new version against the latest git tag using semver
36+
2. If the version is greater, create a git tag, a GitHub Release, and publish to npm
37+
3. Prerelease versions (`alpha`, `beta`, `rc`) are published to the `next` npm tag; stable versions to `latest`
38+
39+
## License
40+
41+
[MIT](./LICENSE) - Copyright (c) 2026 Scope3 Data, Inc.

biome.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/2.4.6/schema.json",
3+
"files": {
4+
"ignoreUnknown": true,
5+
"includes": ["**", "!dist", "!node_modules", "!coverage"]
6+
},
7+
"formatter": {
8+
"enabled": true,
9+
"indentStyle": "space",
10+
"indentWidth": 2,
11+
"lineEnding": "lf",
12+
"lineWidth": 80
13+
},
14+
"linter": {
15+
"enabled": true,
16+
"rules": {
17+
"recommended": true
18+
}
19+
},
20+
"javascript": {
21+
"formatter": {
22+
"quoteStyle": "single",
23+
"semicolons": "asNeeded"
24+
}
25+
}
26+
}

0 commit comments

Comments
 (0)