buildAndRelease.yml 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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 and publish Linux
  127. env:
  128. GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  129. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  130. run: |
  131. cd desktop-app
  132. npm run publish-linux
  133. build-windows-desktop:
  134. name: Build Windows Desktop
  135. needs: create-desktop-release
  136. runs-on: windows-latest
  137. steps:
  138. - uses: actions/checkout@v4
  139. - name: Setup Node.js
  140. uses: actions/setup-node@v4
  141. with:
  142. node-version: '18'
  143. cache: 'npm'
  144. cache-dependency-path: desktop-app/package-lock.json
  145. - name: Copy frontend files
  146. run: |
  147. xcopy "src\main\resources\static\*" "desktop-app\" /E /I /Y
  148. - name: Install dependencies
  149. run: |
  150. cd desktop-app
  151. npm ci
  152. - name: Build and publish Windows
  153. env:
  154. GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  155. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  156. run: |
  157. cd desktop-app
  158. npm run publish-win
  159. build-macos-desktop:
  160. name: Build macOS Desktop
  161. needs: create-desktop-release
  162. runs-on: macos-latest
  163. steps:
  164. - uses: actions/checkout@v4
  165. - name: Setup Node.js
  166. uses: actions/setup-node@v4
  167. with:
  168. node-version: '18'
  169. cache: 'npm'
  170. cache-dependency-path: desktop-app/package-lock.json
  171. - name: Copy frontend files
  172. run: |
  173. cp -r src/main/resources/static/* desktop-app/
  174. - name: Install dependencies
  175. run: |
  176. cd desktop-app
  177. npm ci
  178. - name: Build and publish macOS
  179. env:
  180. GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  181. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  182. run: |
  183. cd desktop-app
  184. npm run publish-mac