99 push :
1010 tags :
1111 - " v*.*.*" # normal release
12+ - ' nightly' # mutable tag
1213
1314permissions :
1415 contents : write
@@ -22,8 +23,12 @@ concurrency:
2223 cancel-in-progress : true
2324
2425jobs :
25- release :
26+ prepare :
2627 runs-on : [ "self-hosted", "ragflow-release" ]
28+ outputs :
29+ release_tag : ${{ steps.release.outputs.release_tag }}
30+ prerelease : ${{ steps.release.outputs.prerelease }}
31+
2732 steps :
2833 - name : Ensure workspace ownership
2934 run : echo "chown -R ${USER} ${GITHUB_WORKSPACE}" && sudo chown -R ${USER} ${GITHUB_WORKSPACE}
3641 fetch-depth : 0
3742 fetch-tags : true
3843
39- - name : Prepare release body
44+ # https://github.com/actions/setup-go
45+ - name : Set up Go
46+ uses : actions/setup-go@v5
47+ with :
48+ go-version-file : go.mod
49+ cache : true
50+
51+ - name : Prepare release metadata
52+ id : release
4053 run : |
4154 if [[ ${GITHUB_EVENT_NAME} != "schedule" ]]; then
4255 RELEASE_TAG=${GITHUB_REF#refs/tags/}
5366 fi
5467 echo "RELEASE_TAG=${RELEASE_TAG}" >> ${GITHUB_ENV}
5568 echo "PRERELEASE=${PRERELEASE}" >> ${GITHUB_ENV}
56- RELEASE_DATETIME=$(date --rfc-3339=seconds)
57- echo Release ${RELEASE_TAG} created from ${GITHUB_SHA} at ${RELEASE_DATETIME} > release_body.md
69+ echo "release_tag=${RELEASE_TAG}" >> ${GITHUB_OUTPUT}
70+ echo "prerelease=${PRERELEASE}" >> ${GITHUB_OUTPUT}
5871
5972 - name : Move the existing mutable tag
6073 # https://github.com/softprops/action-gh-release/issues/171
@@ -72,15 +85,205 @@ jobs:
7285 fi
7386 fi
7487
75- - name : Create or overwrite a release
76- # https://github.com/actions/upload-release-asset has been replaced by https://github.com/softprops/action-gh-release
88+ build_cli :
89+ needs : prepare
90+ strategy :
91+ fail-fast : false
92+ matrix :
93+ include :
94+ - goos : linux
95+ goarch : amd64
96+ runner : ubuntu-24.04
97+ - goos : linux
98+ goarch : arm64
99+ runner : ubuntu-24.04-arm
100+ - goos : darwin
101+ goarch : amd64
102+ runner : macos-15-intel
103+ - goos : darwin
104+ goarch : arm64
105+ runner : macos-14
106+ - goos : windows
107+ goarch : amd64
108+ runner : windows-latest
109+ output_ext : .exe
110+ - goos : windows
111+ goarch : arm64
112+ runner : windows-11-arm
113+ output_ext : .exe
114+ runs-on : ${{ matrix.runner }}
115+ env :
116+ CLI_NAME : ragflow-cli
117+ CLI_MAIN : ./cmd/ragflow-cli.go
118+ DIST_DIR : dist/cli
119+ RELEASE_TAG : ${{ needs.prepare.outputs.release_tag }}
120+
121+ steps :
122+ # https://github.com/actions/checkout/blob/v6/README.md
123+ - name : Check out code
124+ uses : actions/checkout@v6
125+ with :
126+ token : ${{ secrets.GITHUB_TOKEN }}
127+ fetch-depth : 0
128+ fetch-tags : true
129+
130+ # https://github.com/actions/setup-go
131+ - name : Set up Go
132+ uses : actions/setup-go@v5
133+ with :
134+ go-version-file : go.mod
135+ cache : true
136+
137+ - name : Build Go CLI release binaries on non-Windows
138+ if : runner.os != 'Windows'
139+ shell : bash
140+ run : |
141+ set -euo pipefail
142+
143+ mkdir -p "${DIST_DIR}"
144+
145+ if [[ ! -e "${CLI_MAIN}" ]]; then
146+ echo "::error::Go CLI entry does not exist: ${CLI_MAIN}"
147+ echo "::error::Please update CLI_MAIN in .github/workflows/release.yml"
148+ exit 1
149+ fi
150+
151+ echo "Building Go CLI release binaries"
152+ echo "CLI name: ${CLI_NAME}"
153+ echo "CLI main: ${CLI_MAIN}"
154+ echo "Release tag: ${RELEASE_TAG}"
155+ echo "Commit: ${GITHUB_SHA}"
156+
157+ output="${DIST_DIR}/${CLI_NAME}-${RELEASE_TAG}-${{ matrix.goos }}-${{ matrix.goarch }}"
158+ echo "Building ${{ matrix.goos }}/${{ matrix.goarch }} -> ${output}"
159+
160+ CGO_ENABLED=0 \
161+ GOOS="${{ matrix.goos }}" \
162+ GOARCH="${{ matrix.goarch }}" \
163+ go build \
164+ -trimpath \
165+ -ldflags="-s -w -X main.version=${RELEASE_TAG} -X main.commit=${GITHUB_SHA}" \
166+ -o "${output}" \
167+ "${CLI_MAIN}"
168+
169+ chmod +x "${output}"
170+
171+ - name : Build Go CLI release binaries on Windows
172+ if : runner.os == 'Windows'
173+ shell : pwsh
174+ run : |
175+ New-Item -ItemType Directory -Force -Path $env:DIST_DIR | Out-Null
176+
177+ if (-not (Test-Path $env:CLI_MAIN)) {
178+ Write-Error "Go CLI entry does not exist: $env:CLI_MAIN"
179+ exit 1
180+ }
181+
182+ $output = Join-Path $env:DIST_DIR "${env:CLI_NAME}-${env:RELEASE_TAG}-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.output_ext }}"
183+ Write-Host "Building ${{ matrix.goos }}/${{ matrix.goarch }} -> $output"
184+
185+ $env:CGO_ENABLED = "0"
186+ $env:GOOS = "${{ matrix.goos }}"
187+ $env:GOARCH = "${{ matrix.goarch }}"
188+
189+ go build `
190+ -trimpath `
191+ -ldflags="-s -w -X main.version=$env:RELEASE_TAG -X main.commit=$env:GITHUB_SHA" `
192+ -o "$output" `
193+ "$env:CLI_MAIN"
194+
195+ - name : Upload CLI artifact
196+ uses : actions/upload-artifact@v4
197+ with :
198+ name : cli-${{ matrix.goos }}-${{ matrix.goarch }}
199+ path : dist/cli/*
200+ if-no-files-found : error
201+
202+ publish_cli_assets :
203+ needs :
204+ - prepare
205+ - build_cli
206+ runs-on : [ "self-hosted", "ragflow-release" ]
207+
208+ steps :
209+ - name : Ensure workspace ownership
210+ run : echo "chown -R ${USER} ${GITHUB_WORKSPACE}" && sudo chown -R ${USER} ${GITHUB_WORKSPACE}
211+
212+ # https://github.com/actions/checkout/blob/v6/README.md
213+ - name : Check out code
214+ uses : actions/checkout@v6
215+ with :
216+ token : ${{ secrets.GITHUB_TOKEN }}
217+ fetch-depth : 0
218+ fetch-tags : true
219+
220+ - name : Download CLI artifacts
221+ uses : actions/download-artifact@v5
222+ with :
223+ pattern : cli-*
224+ path : dist/cli
225+ merge-multiple : true
226+
227+ - name : Prepare CLI release assets
228+ env :
229+ RELEASE_TAG : ${{ needs.prepare.outputs.release_tag }}
230+ run : |
231+ set -euo pipefail
232+
233+ RELEASE_DATETIME=$(date --rfc-3339=seconds)
234+ echo Release ${RELEASE_TAG} created from ${GITHUB_SHA} at ${RELEASE_DATETIME} > release_body.md
235+
236+ cd dist/cli
237+ sha256sum * > SHA256SUMS
238+ cd -
239+
240+ echo "Generated CLI release assets:"
241+ ls -lh dist/cli
242+
243+ - name : Upload Go CLI release assets
77244 uses : softprops/action-gh-release@v2
78245 with :
79- token : ${{ secrets.GITHUB_TOKEN }} # Use the secret as an environment variable
80- prerelease : ${{ env.PRERELEASE }}
81- tag_name : ${{ env.RELEASE_TAG }}
82- # The body field does not support environment variable substitution directly.
246+ token : ${{ secrets.GITHUB_TOKEN }}
247+ prerelease : ${{ needs.prepare.outputs.prerelease }}
248+ tag_name : ${{ needs.prepare.outputs.release_tag }}
83249 body_path : release_body.md
250+ files : |
251+ dist/cli/*
252+ tools/scripts/install.sh
253+ tools/scripts/install.ps1
254+
255+ release :
256+ needs :
257+ - prepare
258+ - publish_cli_assets
259+ runs-on : [ "self-hosted", "ragflow-release" ]
260+ env :
261+ RELEASE_TAG : ${{ needs.prepare.outputs.release_tag }}
262+
263+ steps :
264+ - name : Ensure workspace ownership
265+ run : echo "chown -R ${USER} ${GITHUB_WORKSPACE}" && sudo chown -R ${USER} ${GITHUB_WORKSPACE}
266+
267+ # https://github.com/actions/checkout/blob/v6/README.md
268+ - name : Check out code
269+ uses : actions/checkout@v6
270+ with :
271+ token : ${{ secrets.GITHUB_TOKEN }}
272+ fetch-depth : 0
273+ fetch-tags : true
274+
275+ - name : Build server binary (with native libs / ORT)
276+ # The production Dockerfile does `COPY bin bin`, so the binary must be
277+ # built (and ORT statically linked from the runner image at
278+ # /opt/ragflow-native-libs) before the docker build. This makes ORT's
279+ # presence in the released image an explicit, visible precondition
280+ # instead of relying on a pre-populated bin/ from elsewhere.
281+ env :
282+ CGO_ENABLED : ' 1'
283+ run : |
284+ set -euo pipefail
285+ ./build.sh --cpp
286+ ./build.sh --go
84287
85288 - name : Build and push image
86289 run : |
0 commit comments