From c7472e1e4c0c9356e6c8580977007bc19588155d Mon Sep 17 00:00:00 2001 From: hxwu Date: Sun, 26 Apr 2026 04:30:58 +0800 Subject: [PATCH 1/3] ci: add release workflow (Docker + GitHub Release) - Add .github/workflows/release.yml triggered only on v* tags - Docker job: build amd64 image and push to GHCR (ghcr.io) - Release job: create GitHub Release with auto release notes - Update docker-compose.yml to use prebuilt GHCR image --- .github/workflows/release.yml | 99 +++++++++++++++++++++++++++++++++++ docker-compose.yml | 4 +- 2 files changed, 100 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..798f2ea --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,99 @@ +name: Release + +on: + push: + tags: ['v*'] + +jobs: + # ────────────────────────────────────────────── + # Job 1: Build & Push Docker Image (GHCR) + # ────────────────────────────────────────────── + docker: + name: Docker Build & Push + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }} + tags: | + type=raw,value=latest + # v2.0.6 -> 2.0.6 + type=semver,pattern={{version}} + # v2.0.6 -> 2.0 + type=semver,pattern={{major}}.{{minor}} + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/amd64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Summary + run: | + echo "## 🐳 Docker Image Published" >> "$GITHUB_STEP_SUMMARY" + echo "" >> "$GITHUB_STEP_SUMMARY" + echo "**Tags:**" >> "$GITHUB_STEP_SUMMARY" + echo '${{ steps.meta.outputs.tags }}' | tr ',' '\n' | sed 's/^/- `/' | sed 's/$/`/' >> "$GITHUB_STEP_SUMMARY" + echo "" >> "$GITHUB_STEP_SUMMARY" + echo "**Platform:** \`linux/amd64\`" >> "$GITHUB_STEP_SUMMARY" + + # ────────────────────────────────────────────── + # Job 2: Create GitHub Release with source code + # ────────────────────────────────────────────── + release: + name: GitHub Release + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Get version from tag + id: version + run: echo "VERSION=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT" + + - name: Check for release notes + id: notes + run: | + NOTES_FILE="RELEASE_NOTES_${{ steps.version.outputs.VERSION }}.md" + if [[ -f "$NOTES_FILE" ]]; then + echo "file=$NOTES_FILE" >> "$GITHUB_OUTPUT" + echo "found=true" >> "$GITHUB_OUTPUT" + else + echo "found=false" >> "$GITHUB_OUTPUT" + fi + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + name: v${{ steps.version.outputs.VERSION }} + body_path: ${{ steps.notes.outputs.found == 'true' && steps.notes.outputs.file || '' }} + generate_release_notes: ${{ steps.notes.outputs.found != 'true' }} + draft: false + prerelease: ${{ contains(github.ref_name, '-') }} diff --git a/docker-compose.yml b/docker-compose.yml index 8c5638b..4a50574 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,8 +1,6 @@ services: windsurf-api: - build: - context: . - dockerfile: Dockerfile + image: ghcr.io/dwgx/windsurf-api:latest # Remove container_name to allow Compose to scale replicas restart: unless-stopped init: true From 2170f16aa2abd5da1f3eb80bc985072a39833900 Mon Sep 17 00:00:00 2001 From: hxwu Date: Sun, 26 Apr 2026 04:56:19 +0800 Subject: [PATCH 2/3] fix: correct indentation in nginx upstream config --- nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nginx.conf b/nginx.conf index 915f946..cfd3589 100644 --- a/nginx.conf +++ b/nginx.conf @@ -27,7 +27,7 @@ http { # Nginx free version requires manual IP listings for sticky sessions, # or we rely on ip_hash for generic load balancing if behind a single reverse proxy. zone windsurf_backend_zone 64k; - server windsurf-api:3003 resolve; + server windsurf-api:3003 resolve; } server { From 5c0e20d470aefb72721ff5bf4c1d9afe391fecfc Mon Sep 17 00:00:00 2001 From: hxwu Date: Sun, 26 Apr 2026 04:59:41 +0800 Subject: [PATCH 3/3] fix: only tag Docker image as latest for stable releases Prevent pre-release tags (e.g. v2.0.7-rc.1) from overwriting :latest tag --- .github/workflows/release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 798f2ea..119800a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -35,7 +35,8 @@ jobs: with: images: ghcr.io/${{ github.repository }} tags: | - type=raw,value=latest + # Only tag as latest for stable releases (no pre-release suffix like -rc, -alpha, -beta) + type=raw,value=latest,enable=${{ !contains(github.ref_name, '-') }} # v2.0.6 -> 2.0.6 type=semver,pattern={{version}} # v2.0.6 -> 2.0