1+ name : Release and Publish
2+
3+ on :
4+ workflow_dispatch :
5+ inputs :
6+ version_type :
7+ description : ' Version type (patch, minor, major)'
8+ required : true
9+ default : ' patch'
10+ type : choice
11+ options :
12+ - patch
13+ - minor
14+ - major
15+ custom_version :
16+ description : ' Custom version (leave empty to use version_type)'
17+ required : false
18+ type : string
19+
20+ jobs :
21+ release-and-publish :
22+ runs-on : ubuntu-latest
23+ steps :
24+ - name : Checkout code
25+ uses : actions/checkout@v4
26+ with :
27+ fetch-depth : 0
28+ token : ${{ secrets.GITHUB_TOKEN }}
29+
30+ - name : Setup Node.js
31+ uses : actions/setup-node@v4
32+ with :
33+ node-version : ' 18.x'
34+ registry-url : ' https://registry.npmjs.org'
35+
36+ - name : Setup Bun
37+ uses : oven-sh/setup-bun@v1
38+ with :
39+ bun-version : latest
40+
41+ - name : Install dependencies
42+ run : bun install
43+
44+ - name : Configure Git
45+ run : |
46+ git config --local user.email "action@github.com"
47+ git config --local user.name "GitHub Action"
48+
49+ - name : Bump version
50+ id : bump_version
51+ run : |
52+ if [ -n "${{ github.event.inputs.custom_version }}" ]; then
53+ echo "Using custom version ${{ github.event.inputs.custom_version }}"
54+ npm version ${{ github.event.inputs.custom_version }} --no-git-tag-version
55+ echo "VERSION=${{ github.event.inputs.custom_version }}" >> $GITHUB_ENV
56+ else
57+ echo "Bumping ${{ github.event.inputs.version_type }} version"
58+ NEW_VERSION=$(npm version ${{ github.event.inputs.version_type }} --no-git-tag-version)
59+ echo "VERSION=${NEW_VERSION:1}" >> $GITHUB_ENV
60+ fi
61+ echo "New version: ${{ env.VERSION }}"
62+
63+ - name : Build project
64+ run : bun run build && bun run build:http
65+
66+ - name : Commit and push changes
67+ run : |
68+ git add package.json
69+ git commit -m "Bump version to v${{ env.VERSION }}"
70+ git push
71+
72+ - name : Create and push tag
73+ run : |
74+ git tag -a v${{ env.VERSION }} -m "Release v${{ env.VERSION }}"
75+ git push --tags
76+
77+ - name : Create GitHub Release
78+ uses : softprops/action-gh-release@v1
79+ with :
80+ tag_name : v${{ env.VERSION }}
81+ name : Release v${{ env.VERSION }}
82+ generate_release_notes : true
83+ env :
84+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
85+
86+ - name : Publish to npm
87+ run : npm publish
88+ env :
89+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
0 commit comments