Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
version: 2
updates:
# Enable version updates for npm
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
timezone: "Europe/Berlin"
day: "monday"
time: "04:00"
open-pull-requests-limit: 5
labels:
- "chore"
commit-message:
prefix: "chore(deps)"
prefix-development: "chore(deps-dev)"
rebase-strategy: "auto"
versioning-strategy: "increase"

# Version updates for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
timezone: "Europe/Berlin"
day: "monday"
time: "04:00"
open-pull-requests-limit: 5
labels:
- "chore"
commit-message:
prefix: "chore(actions)"
144 changes: 144 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
name: Build

env:
NODE_VERSION: "22"

on:
push:
branches:
- "main"
- "develop"
paths:
- "src/**"
- "package.json"
- "package-lock.json"
- "tsconfig.json"
- "tsup.config.ts"
- "biome.json"
- "vitest.config.ts"
- ".github/workflows/build.yml"
pull_request:
paths:
- "src/**"
- "package.json"
- "package-lock.json"
- "tsconfig.json"
- "tsup.config.ts"
- "biome.json"
- "vitest.config.ts"
- ".github/workflows/build.yml"
workflow_dispatch:

jobs:
lint:
name: Lint & Format
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"

- name: Install dependencies
run: npm ci

- name: Run Biome check
run: npm run check

- name: Check TypeScript
run: npm run typecheck

test:
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20, 22]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "npm"

- name: Install dependencies
run: npm ci

- name: Run tests
run: npm run test:coverage

- name: Upload coverage to Codecov
if: matrix.node-version == 22
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage/lcov.info
fail_ci_if_error: false

build:
name: Build
runs-on: ubuntu-latest
needs: [lint, test]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"

- name: Install dependencies
run: npm ci

- name: Build package
run: npm run build

- name: Verify build artifacts
run: |
ls -la dist/
test -f dist/index.js
test -f dist/index.d.ts
test -f dist/client.js
test -f dist/builder.js
test -f dist/errors.js

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
retention-days: 7

publish-dry-run:
name: Publish (Dry Run)
runs-on: ubuntu-latest
needs: [build]
if: github.event_name == 'pull_request'
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
registry-url: "https://registry.npmjs.org"

- name: Install dependencies
run: npm ci

- name: Build package
run: npm run build

- name: Publish dry run
run: npm publish --dry-run
152 changes: 152 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
name: Release

env:
NODE_VERSION: "22"

on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
version:
description: "Version to release (e.g., 1.0.0)"
required: true
type: string

jobs:
validate:
name: Validate Release
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
tag: ${{ steps.version.outputs.tag }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Extract version
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION="${{ inputs.version }}"
TAG="v${VERSION}"
else
TAG="${{ github.ref_name }}"
VERSION="${TAG#v}"
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "tag=${TAG}" >> $GITHUB_OUTPUT
echo "Releasing version: ${VERSION}"

- name: Validate version format
run: |
if ! echo "${{ steps.version.outputs.version }}" | grep -E '^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9-]+(\.[0-9]+)?)?$'; then
echo "Invalid version format: ${{ steps.version.outputs.version }}"
exit 1
fi

- name: Check if tag exists (for manual dispatch)
if: github.event_name == 'workflow_dispatch'
run: |
if git rev-parse "${{ steps.version.outputs.tag }}" >/dev/null 2>&1; then
echo "Tag ${{ steps.version.outputs.tag }} already exists"
exit 1
fi

build:
name: Build Package
runs-on: ubuntu-latest
needs: validate
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"

- name: Install dependencies
run: npm ci

- name: Build package
run: npm run build

- name: Verify build artifacts
run: |
ls -la dist/
test -f dist/index.js
test -f dist/index.d.ts
test -f dist/client.js
test -f dist/builder.js
test -f dist/errors.js

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: dist-${{ needs.validate.outputs.version }}
path: dist/
retention-days: 30

publish:
name: Publish to NPM
runs-on: ubuntu-latest
needs: [validate, build]
environment: release
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
registry-url: "https://registry.npmjs.org"

- name: Install dependencies
run: npm ci

- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: dist-${{ needs.validate.outputs.version }}
path: dist/

- name: Update package.json version
run: npm version ${{ needs.validate.outputs.version }} --no-git-tag-version

- name: Publish to NPM
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.validate.outputs.tag }}
name: Release ${{ needs.validate.outputs.tag }}
body: |
## Release ${{ needs.validate.outputs.version }}

### Installation
```bash
npm install @nvisy/sdk@${{ needs.validate.outputs.version }}
```

### What's New
- See the [CHANGELOG](https://github.com/nvisycom/sdk/blob/main/CHANGELOG.md) for details

### Documentation
- [README](https://github.com/nvisycom/sdk#readme)
- [NPM Package](https://www.npmjs.com/package/@nvisy/sdk)

**Full Changelog**: https://github.com/nvisycom/sdk/compare/v${{ needs.validate.outputs.version }}...HEAD
draft: false
prerelease: ${{ contains(needs.validate.outputs.version, '-') }}
Loading