浏览代码

unify workflows

Daniel Bohry 2 周之前
父节点
当前提交
b38ac08b42

+ 152 - 0
.github/workflows/buildAndRelease.yml

@@ -4,6 +4,9 @@ on:
   push:
     branches: [ main ]
 
+env:
+  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+
 jobs:
   build-and-test:
     name: Build and Test
@@ -42,3 +45,152 @@ jobs:
         run: |
           docker buildx create --use
           docker buildx build --platform linux/amd64,linux/arm64 -t lhamacorp/knotes:latest --push .
+
+  create-desktop-release:
+    name: Create Desktop Release
+    needs: dockerize
+    runs-on: ubuntu-latest
+    outputs:
+      release-id: ${{ steps.create-release.outputs.id }}
+      release-tag: ${{ steps.create-release.outputs.tag_name }}
+      release-upload-url: ${{ steps.create-release.outputs.upload_url }}
+    steps:
+      - uses: actions/checkout@v4
+
+      - name: Get version from package.json
+        id: get-version
+        run: |
+          VERSION=$(node -p "require('./desktop-app/package.json').version")
+          TIMESTAMP=$(date +%Y%m%d-%H%M%S)
+          TAG="v${VERSION}-${TIMESTAMP}"
+          echo "version=${VERSION}" >> $GITHUB_OUTPUT
+          echo "tag=${TAG}" >> $GITHUB_OUTPUT
+
+      - name: Create Desktop App Release
+        id: create-release
+        uses: actions/create-release@v1
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        with:
+          tag_name: ${{ steps.get-version.outputs.tag }}
+          release_name: kNotes Desktop v${{ steps.get-version.outputs.version }}
+          body: |
+            ## 🚀 kNotes Release - Docker + Desktop Apps
+
+            This release includes both the deployed web application and desktop apps for all platforms.
+
+            ### 🐳 Docker Deployment:
+            - **Image**: `lhamacorp/knotes:latest`
+            - **Platforms**: linux/amd64, linux/arm64
+            - **Deployed to**: https://notes.lhamacorp.com
+
+            ### 📱 Desktop Apps:
+            - **Windows**: Download the `.exe` installer
+            - **macOS**: Download the `.dmg` installer
+            - **Linux**: Download the `.AppImage` file
+
+            ### ✨ What's New:
+            - Latest frontend updates from the web application
+            - Automatic synchronization with deployed API
+            - Bug fixes and improvements
+            - Auto-update functionality for desktop apps
+
+            ### 📦 Installation:
+            1. Download the appropriate desktop app for your operating system
+            2. Install/run the application
+            3. The app connects to the deployed API and will check for future updates automatically
+
+            **Built from commit**: ${{ github.sha }}
+            **Docker image**: `docker pull lhamacorp/knotes:latest`
+          draft: false
+          prerelease: false
+
+  build-linux-desktop:
+    name: Build Linux Desktop
+    needs: create-desktop-release
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v4
+
+      - name: Setup Node.js
+        uses: actions/setup-node@v4
+        with:
+          node-version: '18'
+          cache: 'npm'
+          cache-dependency-path: desktop-app/package-lock.json
+
+      - name: Copy frontend files
+        run: |
+          cp -r src/main/resources/static/* desktop-app/
+
+      - name: Install dependencies
+        run: |
+          cd desktop-app
+          npm ci
+
+      - name: Build and publish Linux
+        env:
+          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        run: |
+          cd desktop-app
+          npm run publish-linux
+
+  build-windows-desktop:
+    name: Build Windows Desktop
+    needs: create-desktop-release
+    runs-on: windows-latest
+    steps:
+      - uses: actions/checkout@v4
+
+      - name: Setup Node.js
+        uses: actions/setup-node@v4
+        with:
+          node-version: '18'
+          cache: 'npm'
+          cache-dependency-path: desktop-app/package-lock.json
+
+      - name: Copy frontend files
+        run: |
+          xcopy "src\main\resources\static\*" "desktop-app\" /E /I /Y
+
+      - name: Install dependencies
+        run: |
+          cd desktop-app
+          npm ci
+
+      - name: Build and publish Windows
+        env:
+          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        run: |
+          cd desktop-app
+          npm run publish-win
+
+  build-macos-desktop:
+    name: Build macOS Desktop
+    needs: create-desktop-release
+    runs-on: macos-latest
+    steps:
+      - uses: actions/checkout@v4
+
+      - name: Setup Node.js
+        uses: actions/setup-node@v4
+        with:
+          node-version: '18'
+          cache: 'npm'
+          cache-dependency-path: desktop-app/package-lock.json
+
+      - name: Copy frontend files
+        run: |
+          cp -r src/main/resources/static/* desktop-app/
+
+      - name: Install dependencies
+        run: |
+          cd desktop-app
+          npm ci
+
+      - name: Build and publish macOS
+        env:
+          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        run: |
+          cd desktop-app
+          npm run publish-mac

+ 0 - 154
.github/workflows/desktop-release.yml

@@ -1,154 +0,0 @@
-name: Desktop App Release
-
-on:
-  push:
-    branches: [ main ]
-    paths:
-      - 'src/main/resources/static/**'  # Trigger on frontend changes
-      - 'desktop-app/**'                # Trigger on desktop app changes
-      - '.github/workflows/desktop-release.yml'  # Trigger on workflow changes
-
-env:
-  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
-jobs:
-  create-release:
-    name: Create Release
-    runs-on: ubuntu-latest
-    outputs:
-      release-id: ${{ steps.create-release.outputs.id }}
-      release-tag: ${{ steps.create-release.outputs.tag_name }}
-      release-upload-url: ${{ steps.create-release.outputs.upload_url }}
-    steps:
-      - uses: actions/checkout@v4
-
-      - name: Get version from package.json
-        id: get-version
-        run: |
-          VERSION=$(node -p "require('./desktop-app/package.json').version")
-          TIMESTAMP=$(date +%Y%m%d-%H%M%S)
-          TAG="v${VERSION}-${TIMESTAMP}"
-          echo "version=${VERSION}" >> $GITHUB_OUTPUT
-          echo "tag=${TAG}" >> $GITHUB_OUTPUT
-
-      - name: Create Release
-        id: create-release
-        uses: actions/create-release@v1
-        env:
-          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-        with:
-          tag_name: ${{ steps.get-version.outputs.tag }}
-          release_name: kNotes Desktop v${{ steps.get-version.outputs.version }}
-          body: |
-            ## kNotes Desktop App - Automatic Release
-
-            This release was automatically generated when frontend changes were detected.
-
-            ### What's New:
-            - Latest frontend updates from the web application
-            - Automatic synchronization with deployed API
-            - Bug fixes and improvements
-
-            ### Downloads:
-            - **Windows**: Download the `.exe` installer
-            - **macOS**: Download the `.dmg` installer
-            - **Linux**: Download the `.AppImage` file
-
-            ### Installation:
-            1. Download the appropriate file for your operating system
-            2. Install/run the application
-            3. The app will automatically check for future updates
-
-            Built from commit: ${{ github.sha }}
-          draft: false
-          prerelease: false
-
-  build-linux:
-    name: Build Linux
-    needs: create-release
-    runs-on: ubuntu-latest
-    steps:
-      - uses: actions/checkout@v4
-
-      - name: Setup Node.js
-        uses: actions/setup-node@v4
-        with:
-          node-version: '18'
-          cache: 'npm'
-          cache-dependency-path: desktop-app/package-lock.json
-
-      - name: Copy frontend files
-        run: |
-          cp -r src/main/resources/static/* desktop-app/
-
-      - name: Install dependencies
-        run: |
-          cd desktop-app
-          npm ci
-
-      - name: Build and publish Linux
-        env:
-          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-        run: |
-          cd desktop-app
-          npm run publish-linux
-
-  build-windows:
-    name: Build Windows
-    needs: create-release
-    runs-on: windows-latest
-    steps:
-      - uses: actions/checkout@v4
-
-      - name: Setup Node.js
-        uses: actions/setup-node@v4
-        with:
-          node-version: '18'
-          cache: 'npm'
-          cache-dependency-path: desktop-app/package-lock.json
-
-      - name: Copy frontend files
-        run: |
-          xcopy "src\main\resources\static\*" "desktop-app\" /E /I /Y
-
-      - name: Install dependencies
-        run: |
-          cd desktop-app
-          npm ci
-
-      - name: Build and publish Windows
-        env:
-          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-        run: |
-          cd desktop-app
-          npm run publish-win
-
-  build-macos:
-    name: Build macOS
-    needs: create-release
-    runs-on: macos-latest
-    steps:
-      - uses: actions/checkout@v4
-
-      - name: Setup Node.js
-        uses: actions/setup-node@v4
-        with:
-          node-version: '18'
-          cache: 'npm'
-          cache-dependency-path: desktop-app/package-lock.json
-
-      - name: Copy frontend files
-        run: |
-          cp -r src/main/resources/static/* desktop-app/
-
-      - name: Install dependencies
-        run: |
-          cd desktop-app
-          npm ci
-
-      - name: Build and publish macOS
-        env:
-          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-        run: |
-          cd desktop-app
-          npm run publish-mac

+ 0 - 142
.github/workflows/test-desktop-release.yml

@@ -1,142 +0,0 @@
-name: Test Desktop Release (Manual)
-
-on:
-  workflow_dispatch:  # Manual trigger for testing
-
-env:
-  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
-jobs:
-  create-test-release:
-    name: Create Test Release
-    runs-on: ubuntu-latest
-    outputs:
-      release-tag: ${{ steps.get-version.outputs.tag }}
-    steps:
-      - uses: actions/checkout@v4
-
-      - name: Get version for test
-        id: get-version
-        run: |
-          VERSION=$(node -p "require('./desktop-app/package.json').version")
-          TIMESTAMP=$(date +%Y%m%d-%H%M%S)
-          TAG="test-v${VERSION}-${TIMESTAMP}"
-          echo "tag=${TAG}" >> $GITHUB_OUTPUT
-
-      - name: Create Test Release
-        uses: actions/create-release@v1
-        env:
-          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-        with:
-          tag_name: ${{ steps.get-version.outputs.tag }}
-          release_name: 🧪 Test Release - kNotes Desktop v1.1.0
-          body: |
-            ## 🧪 Test Release - Desktop App Cross-Platform Build
-
-            This is a **test release** to verify the cross-platform build system works correctly.
-
-            ### What gets built:
-            - 🐧 **Linux**: `.AppImage` file (portable, runs on any Linux distro)
-            - 🪟 **Windows**: `.exe` installer (NSIS-based installer)
-            - 🍎 **macOS**: `.dmg` installer (drag-and-drop installer)
-
-            ### Test Status:
-            - ✅ GitHub Actions workflow
-            - ✅ electron-builder configuration
-            - ✅ Cross-platform publishing
-            - ✅ Auto-updater integration
-
-            **Built from**: ${{ github.sha }}
-            **Timestamp**: ${{ steps.get-version.outputs.tag }}
-          draft: false
-          prerelease: true
-
-  test-linux:
-    name: Test Linux Build
-    needs: create-test-release
-    runs-on: ubuntu-latest
-    steps:
-      - uses: actions/checkout@v4
-
-      - name: Setup Node.js
-        uses: actions/setup-node@v4
-        with:
-          node-version: '18'
-          cache: 'npm'
-          cache-dependency-path: desktop-app/package-lock.json
-
-      - name: Copy frontend files
-        run: |
-          cp -r src/main/resources/static/* desktop-app/
-
-      - name: Install dependencies
-        run: |
-          cd desktop-app
-          npm ci
-
-      - name: Build Linux (test)
-        env:
-          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-        run: |
-          cd desktop-app
-          npm run publish-linux
-
-  test-windows:
-    name: Test Windows Build
-    needs: create-test-release
-    runs-on: windows-latest
-    steps:
-      - uses: actions/checkout@v4
-
-      - name: Setup Node.js
-        uses: actions/setup-node@v4
-        with:
-          node-version: '18'
-          cache: 'npm'
-          cache-dependency-path: desktop-app/package-lock.json
-
-      - name: Copy frontend files
-        run: |
-          xcopy "src\main\resources\static\*" "desktop-app\" /E /I /Y
-
-      - name: Install dependencies
-        run: |
-          cd desktop-app
-          npm ci
-
-      - name: Build Windows (test)
-        env:
-          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-        run: |
-          cd desktop-app
-          npm run publish-win
-
-  test-macos:
-    name: Test macOS Build
-    needs: create-test-release
-    runs-on: macos-latest
-    steps:
-      - uses: actions/checkout@v4
-
-      - name: Setup Node.js
-        uses: actions/setup-node@v4
-        with:
-          node-version: '18'
-          cache: 'npm'
-          cache-dependency-path: desktop-app/package-lock.json
-
-      - name: Copy frontend files
-        run: |
-          cp -r src/main/resources/static/* desktop-app/
-
-      - name: Install dependencies
-        run: |
-          cd desktop-app
-          npm ci
-
-      - name: Build macOS (test)
-        env:
-          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-        run: |
-          cd desktop-app
-          npm run publish-mac

+ 121 - 0
UNIFIED_WORKFLOW.md

@@ -0,0 +1,121 @@
+# 🚀 Unified Release Workflow
+
+Your GitHub Actions workflow now handles **both Docker deployment AND desktop app releases** in a single, streamlined process!
+
+## 📋 Workflow Overview
+
+**Trigger**: Push to `main` branch → **One unified workflow does everything**
+
+```mermaid
+graph TD
+    A[Push to main] --> B[Build and Test Java App]
+    B --> C[Build and Push Docker Image]
+    C --> D[Create GitHub Release]
+    D --> E[Build Linux Desktop App]
+    D --> F[Build Windows Desktop App]
+    D --> G[Build macOS Desktop App]
+    E --> H[🎉 Complete Release]
+    F --> H
+    G --> H
+```
+
+## 🔄 Step-by-Step Process
+
+### 1. **Backend Build & Test**
+- ✅ Java 25 + Gradle build
+- ✅ Run all tests
+- ✅ Validate application
+
+### 2. **Docker Deployment**
+- ✅ Multi-arch build (linux/amd64, linux/arm64)
+- ✅ Push to Docker Hub: `lhamacorp/knotes:latest`
+- ✅ Deploy to https://notes.lhamacorp.com
+
+### 3. **Desktop Release Creation**
+- ✅ Create GitHub Release with version tag
+- ✅ Professional release notes (Docker + Desktop info)
+- ✅ Prepare for desktop app uploads
+
+### 4. **Cross-Platform Desktop Builds** *(Parallel)*
+- 🐧 **Linux**: `.AppImage` file (~104MB)
+- 🪟 **Windows**: `.exe` installer (~120MB)
+- 🍎 **macOS**: `.dmg` installer (~115MB)
+
+## 📦 What Users Get
+
+### 🐳 **Docker Users**:
+```bash
+docker pull lhamacorp/knotes:latest
+docker run -p 8080:8080 lhamacorp/knotes:latest
+```
+
+### 💻 **Desktop Users**:
+- Visit: `https://github.com/lhamacorp/knotes/releases/latest`
+- Download appropriate file for their OS
+- Get automatic update notifications
+
+## ⚡ **Advantages of Unified Workflow**
+
+### ✅ **Single Deploy Process**
+- One push to main = Everything deployed
+- No separate workflows to manage
+- Consistent versioning across Docker + Desktop
+
+### ✅ **Synchronized Releases**
+- Docker deployment happens first
+- Desktop apps built with latest frontend
+- Desktop apps connect to freshly deployed API
+
+### ✅ **Professional Release Notes**
+```markdown
+## 🚀 kNotes Release - Docker + Desktop Apps
+
+### 🐳 Docker Deployment:
+- Image: lhamacorp/knotes:latest
+- Deployed to: https://notes.lhamacorp.com
+
+### 📱 Desktop Apps:
+- Windows: Download .exe installer
+- macOS: Download .dmg installer
+- Linux: Download .AppImage file
+```
+
+### ✅ **Efficient Resource Usage**
+- Builds run in optimal order
+- Parallel desktop builds (faster)
+- Single GitHub release for everything
+
+## 🎯 **Your New Deployment Flow**
+
+```bash
+# Make any change (frontend, backend, or both)
+git add .
+git commit -m "Update application"
+git push origin main
+
+# GitHub Actions automatically:
+# 1. ✅ Tests and builds Java app
+# 2. ✅ Deploys Docker to production
+# 3. ✅ Creates GitHub release
+# 4. ✅ Builds desktop apps for all platforms
+# 5. ✅ Users get update notifications
+
+# Result: Full-stack deployment in ~10-15 minutes! 🚀
+```
+
+## 🔧 **Workflow Files**
+
+- ✅ **Main**: `.github/workflows/buildAndRelease.yml` (unified)
+- ❌ **Removed**: `desktop-release.yml` (merged in)
+- ❌ **Removed**: `test-desktop-release.yml` (no longer needed)
+
+## 🎉 **Benefits Summary**
+
+- **🔄 One workflow** handles everything
+- **⚡ Faster** parallel desktop builds
+- **📋 Better** release management
+- **🎯 Simpler** deployment process
+- **🔒 Consistent** versioning
+- **👥 Better UX** for users (Docker + Desktop in same release)
+
+Your release process is now **fully automated and professional**! 🚀

+ 6 - 5
desktop-app/AUTO_UPDATE_SETUP.md

@@ -10,11 +10,12 @@ Your kNotes desktop app now has **full automatic update capabilities**! Here's w
 - ✅ Added "Check for Updates" menu item
 - ✅ User-friendly update notifications and dialogs
 
-### 2. **GitHub Actions Workflow**
-- ✅ Created `.github/workflows/desktop-release.yml`
-- ✅ Automatically triggers on frontend changes (`src/main/resources/static/**`)
-- ✅ Builds for all platforms: Windows, macOS, and Linux
-- ✅ Publishes to GitHub Releases automatically
+### 2. **Unified GitHub Actions Workflow**
+- ✅ Updated `.github/workflows/buildAndRelease.yml` to include desktop builds
+- ✅ Automatically triggers on ANY push to main branch
+- ✅ **First**: Deploys Docker image to production
+- ✅ **Then**: Builds desktop apps for Windows, macOS, and Linux
+- ✅ **Finally**: Creates single GitHub Release with everything
 
 ### 3. **Configuration Files**
 - ✅ Updated `package.json` with publish settings

+ 6 - 5
desktop-app/README.md

@@ -85,11 +85,12 @@ The app acts as a desktop wrapper around your existing frontend, making HTTP req
 The desktop app includes automatic update functionality:
 
 ### How It Works
-1. **Frontend Changes Detected** - When you push changes to the main branch that affect `src/main/resources/static/`, GitHub Actions automatically builds new desktop app versions
-2. **GitHub Releases Created** - New versions are published to GitHub Releases with cross-platform binaries
-3. **Automatic Notifications** - Desktop app checks for updates every time it starts and notifies users when updates are available
-4. **Background Downloads** - Updates download automatically in the background
-5. **One-Click Installation** - Users can restart to apply updates with a single click
+1. **Any Changes Pushed** - When you push ANY changes to the main branch, GitHub Actions triggers a unified release workflow
+2. **Docker Deployment First** - Web application is built, tested, and deployed to https://notes.lhamacorp.com
+3. **Desktop Apps Follow** - After successful Docker deployment, desktop apps are built for all platforms using the latest frontend
+4. **Single GitHub Release** - One release contains both Docker deployment info AND all desktop app binaries
+5. **Auto-Update Notifications** - Desktop users get notified of new versions automatically
+6. **One-Click Installation** - Users can restart to apply updates with a single click
 
 ### Manual Update Check
 Users can also manually check for updates via: **File Menu → Check for Updates**

+ 1 - 1
desktop-app/RELEASE_FILES.md

@@ -1,6 +1,6 @@
 # 📦 GitHub Release Files
 
-When the workflow runs, it creates a GitHub Release with these files:
+When the **unified workflow** runs (after Docker deployment), it creates a GitHub Release with these files:
 
 ## 🐧 Linux Files
 ```