Skip to content

Commit af88dbe

Browse files
authored
Add release automation with tests (#127)
* added release automation with tests * added explict node verion * handle linux in generate api * removed lock file for example * removed unused vite plugin * updated vite config
1 parent 5bde544 commit af88dbe

19 files changed

Lines changed: 1103 additions & 3 deletions

.github/workflows/ci.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
compile:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout repo
15+
uses: actions/checkout@v4
16+
17+
- name: Set up node
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: 22
21+
22+
- name: Install dependencies
23+
run: npm ci
24+
25+
- name: Generate API
26+
run: npm run generate-api
27+
28+
- name: Build sdk
29+
run: npm run build
30+
31+
- name: Run tests
32+
run: npm test
33+
34+
- name: Test example project
35+
run: npm run test:example

.github/workflows/release.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
release:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout repo
12+
uses: actions/checkout@v4
13+
with:
14+
token: ${{ secrets.GITHUB_TOKEN }}
15+
fetch-depth: 0
16+
17+
- name: Set up Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version-file: 'package.json'
21+
registry-url: 'https://registry.npmjs.org'
22+
23+
- name: Extract version from tag
24+
id: extract_version
25+
run: |
26+
VERSION=${GITHUB_REF#refs/tags/v}
27+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
28+
echo "Extracted version: $VERSION"
29+
30+
- name: Verify version matches package.json
31+
run: |
32+
PACKAGE_VERSION=$(node -p "require('./package.json').version")
33+
TAG_VERSION=${{ steps.extract_version.outputs.VERSION }}
34+
35+
echo "Package.json version: $PACKAGE_VERSION"
36+
echo "Tag version: $TAG_VERSION"
37+
38+
if [ "$PACKAGE_VERSION" != "$TAG_VERSION" ]; then
39+
echo "❌ Version mismatch! Package.json version ($PACKAGE_VERSION) does not match tag version ($TAG_VERSION)"
40+
echo "Please ensure the package.json version matches the release tag before publishing."
41+
exit 1
42+
fi
43+
44+
echo "✅ Version verification passed: $PACKAGE_VERSION = $TAG_VERSION"
45+
46+
- name: Install dependencies
47+
run: npm ci
48+
49+
- name: Build
50+
run: npm run build
51+
52+
- name: Run tests
53+
run: npm test
54+
55+
- name: Publish to npm
56+
run: |
57+
if [[ "${{ github.event.release.prerelease }}" == "true" ]]; then
58+
if [[ "${{ steps.extract_version.outputs.VERSION }}" == *"alpha"* ]]; then
59+
npm publish --access public --tag alpha
60+
elif [[ "${{ steps.extract_version.outputs.VERSION }}" == *"beta"* ]]; then
61+
npm publish --access public --tag beta
62+
else
63+
npm publish --access public --tag next
64+
fi
65+
else
66+
npm publish --access public
67+
fi
68+
env:
69+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/update-deps.yml

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
name: Update Dependencies and API
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version_bump:
7+
description: 'Version bump type'
8+
required: true
9+
type: choice
10+
options:
11+
- patch
12+
- minor
13+
- major
14+
default: patch
15+
update_dependencies:
16+
description: 'Update dependencies'
17+
required: true
18+
type: boolean
19+
default: true
20+
generate_api:
21+
description: 'Generate API'
22+
required: true
23+
type: boolean
24+
default: true
25+
26+
jobs:
27+
update:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: Checkout repo
31+
uses: actions/checkout@v4
32+
with:
33+
token: ${{ secrets.GITHUB_TOKEN }}
34+
fetch-depth: 0
35+
36+
- name: Set up Node.js
37+
uses: actions/setup-node@v4
38+
with:
39+
node-version-file: 'package.json'
40+
41+
- name: Configure Git
42+
run: |
43+
git config --global user.name "github-actions[bot]"
44+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
45+
46+
- name: Install dependencies
47+
run: npm ci
48+
49+
- name: Update dependencies
50+
if: ${{ inputs.update_dependencies }}
51+
run: |
52+
echo "🔄 Updating dependencies..."
53+
# Update all dependencies to latest versions
54+
npm update
55+
# Specifically update daily-co to latest
56+
npm install @daily-co/daily-js@latest --save
57+
echo "✅ Dependencies updated"
58+
59+
- name: Generate API
60+
if: ${{ inputs.generate_api }}
61+
run: |
62+
echo "🔄 Generating API..."
63+
chmod +x ./generate-api.sh
64+
npm run generate-api
65+
echo "✅ API generated"
66+
67+
- name: Bump version
68+
id: version
69+
run: |
70+
echo "🔄 Bumping version (${{ inputs.version_bump }})..."
71+
NEW_VERSION=$(npm version ${{ inputs.version_bump }} --no-git-tag-version)
72+
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_OUTPUT
73+
echo "✅ Version bumped to $NEW_VERSION"
74+
75+
- name: Build and test
76+
run: |
77+
echo "🔄 Building and testing..."
78+
npm run build
79+
npm test || echo "⚠️ Tests failed but continuing..."
80+
echo "✅ Build completed"
81+
82+
- name: Test example project
83+
run: npm run test:example
84+
85+
- name: Check for changes
86+
id: changes
87+
run: |
88+
if [ -n "$(git status --porcelain)" ]; then
89+
echo "HAS_CHANGES=true" >> $GITHUB_OUTPUT
90+
echo "✅ Changes detected"
91+
else
92+
echo "HAS_CHANGES=false" >> $GITHUB_OUTPUT
93+
echo "ℹ️ No changes detected"
94+
fi
95+
96+
- name: Create Pull Request
97+
if: steps.changes.outputs.HAS_CHANGES == 'true'
98+
uses: peter-evans/create-pull-request@v6
99+
with:
100+
token: ${{ secrets.GITHUB_TOKEN }}
101+
commit-message: |
102+
chore: update dependencies and bump version to ${{ steps.version.outputs.NEW_VERSION }}
103+
104+
- Update dependencies to latest versions
105+
- Regenerate API definitions
106+
- Bump version to ${{ steps.version.outputs.NEW_VERSION }}
107+
title: "chore: update dependencies and bump version to ${{ steps.version.outputs.NEW_VERSION }}"
108+
body: |
109+
## 🔄 Automated Update
110+
111+
This PR contains automated updates:
112+
113+
### Changes Made
114+
- ✅ **Dependencies**: ${{ inputs.update_dependencies && 'Updated to latest versions' || 'Skipped' }}
115+
- ✅ **API Generation**: ${{ inputs.generate_api && 'Regenerated API definitions' || 'Skipped' }}
116+
- ✅ **Version Bump**: Bumped version to `${{ steps.version.outputs.NEW_VERSION }}` (${{ inputs.version_bump }})
117+
118+
### Files Changed
119+
- `package.json` - Version bumped
120+
- `package-lock.json` - Dependencies updated
121+
- `api.ts` - API definitions regenerated (if applicable)
122+
123+
### Next Steps
124+
1. Review the changes
125+
2. Merge this PR
126+
3. Create a GitHub release with tag `${{ steps.version.outputs.NEW_VERSION }}`
127+
4. The release workflow will automatically publish to npm
128+
129+
---
130+
*This PR was created automatically by the Update Dependencies workflow.*
131+
branch: update-deps-${{ steps.version.outputs.NEW_VERSION }}
132+
delete-branch: true
133+
draft: false
134+
135+
- name: Summary
136+
run: |
137+
if [ "${{ steps.changes.outputs.HAS_CHANGES }}" == "true" ]; then
138+
echo "✅ Pull request created successfully!"
139+
echo "📋 Summary:"
140+
echo " - Version: ${{ steps.version.outputs.NEW_VERSION }}"
141+
echo " - Dependencies updated: ${{ inputs.update_dependencies }}"
142+
echo " - API generated: ${{ inputs.generate_api }}"
143+
else
144+
echo "ℹ️ No changes were made, so no PR was created."
145+
fi

.npmignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Development files
2+
example/
3+
scripts/
4+
__tests__/
5+
6+
# Build artifacts
7+
*.tgz
8+
*.log
9+
10+
# Git and CI files
11+
.git/
12+
.github/
13+
.gitignore
14+
15+
# Development configuration
16+
.nvmrc
17+
.prettierrc
18+
jest.config.ts
19+
tsconfig.json
20+
21+
# Documentation and scripts
22+
README.md
23+
RELEASE.md
24+
generate-api.sh
25+
update.sh

.nvmrc

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

0 commit comments

Comments
 (0)