buildAndRelease.yml 9.4 KB

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