buildAndRelease.yml 9.0 KB

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