Skip to content

Commit 3184cbb

Browse files
author
Mohamad Yusup S.Tr.Stat
committed
feat: setup automated releases with Release Please
- Add Release Please workflow for automated versioning - Configure conventional commits for semantic versioning - Set up automated NPM publishing on release - Remove manual release workflow in favor of automation - Add comprehensive documentation for release process
1 parent ece5d7f commit 3184cbb

File tree

13 files changed

+1086
-103
lines changed

13 files changed

+1086
-103
lines changed

.github/workflows/deploy-docs.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
name: Deploy Documentation to GitHub Pages
22

33
on:
4-
# Runs on releases
5-
release:
6-
types: [published]
7-
84
# Allows you to run this workflow manually from the Actions tab
95
workflow_dispatch:
6+
inputs:
7+
reason:
8+
description: 'Reason for manual documentation deployment'
9+
required: false
10+
default: 'Manual documentation update'
1011

1112
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
1213
permissions:
@@ -59,3 +60,11 @@ jobs:
5960
- name: Deploy to GitHub Pages
6061
id: deployment
6162
uses: actions/deploy-pages@v4
63+
64+
- name: Summary
65+
run: |
66+
echo "## 📚 Documentation Deployment Summary" >> $GITHUB_STEP_SUMMARY
67+
echo "✅ Documentation successfully deployed to GitHub Pages" >> $GITHUB_STEP_SUMMARY
68+
echo "🔗 **Documentation URL:** ${{ steps.deployment.outputs.page_url }}" >> $GITHUB_STEP_SUMMARY
69+
echo "📝 **Reason:** ${{ github.event.inputs.reason || 'Manual documentation update' }}" >> $GITHUB_STEP_SUMMARY
70+
echo "🕐 **Deployed at:** $(date)" >> $GITHUB_STEP_SUMMARY

.github/workflows/npm-publish.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Release Please
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
12+
jobs:
13+
release-please:
14+
runs-on: ubuntu-latest
15+
outputs:
16+
release_created: ${{ steps.release.outputs.release_created }}
17+
tag_name: ${{ steps.release.outputs.tag_name }}
18+
steps:
19+
- uses: google-github-actions/release-please-action@v4
20+
id: release
21+
with:
22+
release-type: node
23+
package-name: waha-api-client-ts
24+
25+
publish:
26+
runs-on: ubuntu-latest
27+
needs: release-please
28+
if: ${{ needs.release-please.outputs.release_created }}
29+
30+
permissions:
31+
contents: read
32+
id-token: write
33+
34+
steps:
35+
- name: Checkout code
36+
uses: actions/checkout@v4
37+
38+
- name: Setup Node.js
39+
uses: actions/setup-node@v4
40+
with:
41+
node-version: '20'
42+
registry-url: 'https://registry.npmjs.org'
43+
44+
- name: Install dependencies
45+
run: npm ci
46+
47+
- name: Build project
48+
run: npm run build
49+
50+
- name: Run tests
51+
run: npm test
52+
53+
- name: Verify package contents
54+
run: |
55+
echo "## 📦 Package Contents" >> $GITHUB_STEP_SUMMARY
56+
echo "Verifying build outputs..." >> $GITHUB_STEP_SUMMARY
57+
ls -la dist/ >> $GITHUB_STEP_SUMMARY
58+
echo "" >> $GITHUB_STEP_SUMMARY
59+
echo "Package size analysis:" >> $GITHUB_STEP_SUMMARY
60+
du -h dist/* >> $GITHUB_STEP_SUMMARY
61+
62+
- name: Publish to NPM
63+
run: npm publish --provenance --access public
64+
env:
65+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
66+
67+
- name: Success Summary
68+
run: |
69+
echo "## 🎉 NPM Package Published Successfully!" >> $GITHUB_STEP_SUMMARY
70+
echo "✅ Package **${{ needs.release-please.outputs.tag_name }}** has been published to NPM" >> $GITHUB_STEP_SUMMARY
71+
echo "🔗 **NPM Package:** https://www.npmjs.com/package/waha-api-client-ts" >> $GITHUB_STEP_SUMMARY
72+
echo "🕐 **Published at:** $(date)" >> $GITHUB_STEP_SUMMARY

.npmrc

Whitespace-only changes.

.release-please-config.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"release-type": "node",
3+
"package-name": "waha-api-client-ts",
4+
"changelog-sections": [
5+
{"type": "feat", "section": "Features"},
6+
{"type": "fix", "section": "Bug Fixes"},
7+
{"type": "chore", "section": "Miscellaneous"},
8+
{"type": "docs", "section": "Documentation"},
9+
{"type": "style", "section": "Styles"},
10+
{"type": "refactor", "section": "Code Refactoring"},
11+
{"type": "perf", "section": "Performance Improvements"},
12+
{"type": "test", "section": "Tests"},
13+
{"type": "build", "section": "Build System"},
14+
{"type": "ci", "section": "Continuous Integration"}
15+
]
16+
}

.release-please-manifest.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "1.0.0"
3+
}

README.md

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -602,66 +602,10 @@ npm install
602602
npx tsx src/demo.ts
603603
```
604604

605-
## Publishing to NPM and Documentation
606-
607-
This library is automatically published to NPM and its API documentation is deployed to GitHub Pages when a new release is created. The GitHub Actions workflows handle:
608-
609-
1. Building the TypeScript code
610-
2. Running tests
611-
3. Publishing to NPM with provenance
612-
4. Generating API documentation with TypeDoc
613-
5. Deploying documentation to GitHub Pages
614-
615-
### Setup for NPM Publishing
616-
617-
To enable automatic publishing, you need to:
618-
619-
1. Create an NPM access token:
620-
- Go to https://www.npmjs.com/settings/YOUR_USERNAME/tokens
621-
- Create a new "Automation" token
622-
623-
2. Add the token to GitHub repository secrets:
624-
- Go to repository Settings → Secrets and variables → Actions
625-
- Create a new repository secret named `NPM_TOKEN`
626-
- Paste your NPM access token as the value
627-
628-
### Setup for GitHub Pages
629-
630-
To enable automatic documentation deployment:
631-
632-
1. Go to repository Settings → Pages
633-
2. Under "Build and deployment", select "GitHub Actions" as the source
634-
3. Save the settings
635-
636-
### Creating a Release
637-
638-
When you're ready to publish a new version:
639-
640-
1. Update the version in `package.json` (e.g., from `1.0.0` to `1.0.1`)
641-
2. Commit your changes
642-
3. Go to the repository's Releases page
643-
4. Click "Create a new release"
644-
5. Create a new tag matching the version (e.g., `v1.0.1`)
645-
6. Write release notes describing the changes
646-
7. Publish the release
647-
648-
The GitHub Actions workflows will automatically:
649-
- Build and publish the package to NPM
650-
- Generate and deploy API documentation to GitHub Pages (available at `https://[YOUR-USERNAME].github.io/waha-api-client-ts/`)
651-
652-
### Manual Documentation Deployment
653-
654-
You can also manually trigger documentation deployment:
655-
656-
1. Go to the Actions tab in the repository
657-
2. Select "Deploy Documentation to GitHub Pages" workflow
658-
3. Click "Run workflow"
659-
4. Select the branch and run
660-
661605
### Viewing Documentation
662606

663607
Once deployed, the API documentation will be available at:
664-
- **GitHub Pages**: `https://[YOUR-USERNAME].github.io/waha-api-client-ts/`
608+
- **GitHub Pages**: `https://myusp.github.io/waha-api-client-ts/`
665609

666610
You can also generate documentation locally:
667611
```bash

src/demo.ts renamed to example/demo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* 4. All available API methods
99
*/
1010

11-
import { WAHAClient } from './client';
11+
import { WAHAClient } from '../src/client';
1212

1313
console.log('='.repeat(60));
1414
console.log('WAHA API Client - Complete Feature Demonstration');

src/example.ts renamed to example/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Example usage of WAHA API Client
33
*/
44

5-
import { WAHAClient } from './client';
5+
import { WAHAClient } from '../src/client';
66

77
// Example: Initialize client with default configuration
88
const client = new WAHAClient({

0 commit comments

Comments
 (0)