buildAndRelease.yml 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. name: Release
  2. on:
  3. push:
  4. branches: [ main ]
  5. permissions:
  6. contents: write
  7. issues: write
  8. pull-requests: write
  9. env:
  10. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  11. jobs:
  12. build-and-test:
  13. name: Build and Test
  14. runs-on: ubuntu-latest
  15. steps:
  16. - uses: actions/checkout@v3
  17. - name: Set up JDK
  18. uses: actions/setup-java@v3
  19. with:
  20. java-version: '25'
  21. distribution: 'temurin'
  22. - name: Build with Gradle
  23. run: chmod +x ./gradlew && ./gradlew clean build test
  24. dockerize:
  25. name: Dockerize Application
  26. needs: build-and-test
  27. runs-on: ubuntu-latest
  28. steps:
  29. - uses: actions/checkout@v3
  30. - name: Set up JDK
  31. uses: actions/setup-java@v3
  32. with:
  33. java-version: '25'
  34. distribution: 'temurin'
  35. - name: Build
  36. run: chmod +x ./gradlew && ./gradlew build
  37. - name: Set up Docker Buildx
  38. uses: docker/setup-buildx-action@v2
  39. - name: Login to Docker Hub
  40. uses: docker/login-action@v2
  41. with:
  42. username: ${{ secrets.DOCKERHUB_USERNAME }}
  43. password: ${{ secrets.DOCKERHUB_TOKEN }}
  44. - name: Build and Push Image
  45. run: |
  46. docker buildx create --use
  47. docker buildx build --platform linux/amd64,linux/arm64 -t lhamacorp/knotes:latest --push .
  48. create-desktop-release:
  49. name: Create Desktop Release
  50. needs: dockerize
  51. runs-on: ubuntu-latest
  52. outputs:
  53. release-tag: ${{ steps.get-version.outputs.tag }}
  54. release-version: ${{ steps.get-version.outputs.version }}
  55. steps:
  56. - uses: actions/checkout@v4
  57. - name: Get version from package.json
  58. id: get-version
  59. run: |
  60. VERSION=$(node -p "require('./desktop-app/package.json').version")
  61. TIMESTAMP=$(date +%Y%m%d-%H%M%S)
  62. TAG="v${VERSION}-${TIMESTAMP}"
  63. echo "version=${VERSION}" >> $GITHUB_OUTPUT
  64. echo "tag=${TAG}" >> $GITHUB_OUTPUT
  65. - name: Create Desktop App Release
  66. id: create-release
  67. env:
  68. GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  69. run: |
  70. TAG="${{ steps.get-version.outputs.tag }}"
  71. VERSION="${{ steps.get-version.outputs.version }}"
  72. # Create release notes
  73. cat > release-notes.md << 'EOF'
  74. ## 🚀 kNotes Release - Docker + Desktop Apps
  75. This release includes both the deployed web application and desktop apps for all platforms.
  76. ### 🐳 Docker Deployment:
  77. - **Image**: `lhamacorp/knotes:latest`
  78. - **Platforms**: linux/amd64, linux/arm64
  79. - **Deployed to**: https://notes.lhamacorp.com
  80. ### 📱 Desktop Apps:
  81. - **Windows**: Download the `.exe` installer
  82. - **macOS**: Download the `.dmg` installer
  83. - **Linux**: Download the `.AppImage` file
  84. ### ✨ What's New:
  85. - Latest frontend updates from the web application
  86. - Automatic synchronization with deployed API
  87. - Bug fixes and improvements
  88. - Auto-update functionality for desktop apps
  89. ### 📦 Installation:
  90. 1. Download the appropriate desktop app for your operating system
  91. 2. Install/run the application
  92. 3. The app connects to the deployed API and will check for future updates automatically
  93. **Built from commit**: ${{ github.sha }}
  94. **Docker image**: `docker pull lhamacorp/knotes:latest`
  95. EOF
  96. # Create release using GitHub CLI
  97. gh release create "$TAG" \
  98. --title "kNotes Desktop v${VERSION}" \
  99. --notes-file release-notes.md \
  100. --latest || {
  101. echo "Release already exists, updating it..."
  102. gh release edit "$TAG" \
  103. --title "kNotes Desktop v${VERSION}" \
  104. --notes-file release-notes.md \
  105. --latest
  106. }
  107. build-linux-desktop:
  108. name: Build Linux Desktop
  109. needs: create-desktop-release
  110. runs-on: ubuntu-latest
  111. steps:
  112. - uses: actions/checkout@v4
  113. - name: Setup Node.js
  114. uses: actions/setup-node@v4
  115. with:
  116. node-version: '18'
  117. cache: 'npm'
  118. cache-dependency-path: desktop-app/package-lock.json
  119. - name: Copy frontend files
  120. run: |
  121. cp -r src/main/resources/static/* desktop-app/
  122. - name: Install dependencies
  123. run: |
  124. cd desktop-app
  125. npm ci
  126. - name: Build Linux Desktop App
  127. run: |
  128. cd desktop-app
  129. npm run build-linux
  130. - name: Debug Build Output
  131. run: |
  132. cd desktop-app
  133. echo "=== Build Output ==="
  134. ls -la dist/ || echo "No dist directory"
  135. echo "=== End Build Output ==="
  136. - name: Upload Linux Build to Release
  137. env:
  138. GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  139. run: |
  140. cd desktop-app
  141. TAG="${{ needs.create-desktop-release.outputs.release-tag }}"
  142. echo "Uploading to release: $TAG"
  143. # Check if AppImage exists
  144. if ls dist/kNotes-*.AppImage 1> /dev/null 2>&1; then
  145. echo "Found AppImage files:"
  146. ls -la dist/kNotes-*.AppImage
  147. gh release upload "$TAG" dist/kNotes-*.AppImage --clobber
  148. else
  149. echo "No AppImage files found"
  150. fi
  151. # Upload additional files if they exist
  152. if [ -f "dist/latest-linux.yml" ]; then
  153. gh release upload "$TAG" dist/latest-linux.yml --clobber
  154. fi
  155. build-windows-desktop:
  156. name: Build Windows Desktop
  157. needs: create-desktop-release
  158. runs-on: windows-latest
  159. steps:
  160. - uses: actions/checkout@v4
  161. - name: Setup Node.js
  162. uses: actions/setup-node@v4
  163. with:
  164. node-version: '18'
  165. cache: 'npm'
  166. cache-dependency-path: desktop-app/package-lock.json
  167. - name: Copy frontend files
  168. run: |
  169. xcopy "src\main\resources\static\*" "desktop-app\" /E /I /Y
  170. - name: Install dependencies
  171. run: |
  172. cd desktop-app
  173. npm ci
  174. - name: Build Windows Desktop App
  175. run: |
  176. cd desktop-app
  177. npm run build-win
  178. - name: Debug Windows Build Output
  179. run: |
  180. cd desktop-app
  181. echo "=== Windows Build Output ==="
  182. ls -la dist/ || echo "No dist directory"
  183. echo "=== End Windows Build Output ==="
  184. - name: Upload Windows Build to Release
  185. env:
  186. GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  187. run: |
  188. cd desktop-app
  189. TAG="${{ needs.create-desktop-release.outputs.release-tag }}"
  190. echo "Uploading to release: $TAG"
  191. # Check if EXE exists
  192. if ls dist/*.exe 1> /dev/null 2>&1; then
  193. echo "Found Windows installer files:"
  194. ls -la dist/*.exe
  195. gh release upload "$TAG" dist/*.exe --clobber
  196. else
  197. echo "No Windows installer files found"
  198. fi
  199. # Upload additional files if they exist
  200. if [ -f "dist/latest.yml" ]; then
  201. gh release upload "$TAG" dist/latest.yml --clobber
  202. fi
  203. build-macos-desktop:
  204. name: Build macOS Desktop
  205. needs: create-desktop-release
  206. runs-on: macos-latest
  207. steps:
  208. - uses: actions/checkout@v4
  209. - name: Setup Node.js
  210. uses: actions/setup-node@v4
  211. with:
  212. node-version: '18'
  213. cache: 'npm'
  214. cache-dependency-path: desktop-app/package-lock.json
  215. - name: Copy frontend files
  216. run: |
  217. cp -r src/main/resources/static/* desktop-app/
  218. - name: Install dependencies
  219. run: |
  220. cd desktop-app
  221. npm ci
  222. - name: Build macOS Desktop App
  223. run: |
  224. cd desktop-app
  225. npm run build-mac
  226. - name: Debug macOS Build Output
  227. run: |
  228. cd desktop-app
  229. echo "=== macOS Build Output ==="
  230. ls -la dist/ || echo "No dist directory"
  231. echo "=== End macOS Build Output ==="
  232. - name: Upload macOS Build to Release
  233. env:
  234. GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  235. run: |
  236. cd desktop-app
  237. TAG="${{ needs.create-desktop-release.outputs.release-tag }}"
  238. echo "Uploading to release: $TAG"
  239. # Check if DMG exists
  240. if ls dist/*.dmg 1> /dev/null 2>&1; then
  241. echo "Found macOS installer files:"
  242. ls -la dist/*.dmg
  243. gh release upload "$TAG" dist/*.dmg --clobber
  244. else
  245. echo "No macOS installer files found"
  246. fi
  247. # Upload additional files if they exist
  248. if [ -f "dist/latest-mac.yml" ]; then
  249. gh release upload "$TAG" dist/latest-mac.yml --clobber
  250. fi