mirror of
https://github.com/OwO-Network/DeepLX.git
synced 2026-06-11 15:28:50 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
88a00874c8 | ||
|
|
231393c669 | ||
|
|
9d6b294a61 | ||
|
|
d19a3902df | ||
|
|
3f099d187c | ||
|
|
1b88e428ae |
51
.github/workflows/release.yaml
vendored
51
.github/workflows/release.yaml
vendored
@ -5,11 +5,28 @@ on:
|
||||
pull_request:
|
||||
|
||||
name: Release
|
||||
|
||||
jobs:
|
||||
|
||||
Build:
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- { goos: darwin, goarch: amd64 }
|
||||
- { goos: darwin, goarch: arm64 }
|
||||
- { goos: linux, goarch: '386' }
|
||||
- { goos: linux, goarch: amd64 }
|
||||
- { goos: linux, goarch: arm64 }
|
||||
- { goos: linux, goarch: mips }
|
||||
- { goos: openbsd, goarch: amd64 }
|
||||
- { goos: openbsd, goarch: arm64 }
|
||||
- { goos: freebsd, goarch: amd64 }
|
||||
- { goos: freebsd, goarch: arm64 }
|
||||
- { goos: windows, goarch: '386' }
|
||||
- { goos: windows, goarch: amd64 }
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
@ -17,12 +34,40 @@ jobs:
|
||||
with:
|
||||
go-version: "1.24.2"
|
||||
|
||||
- run: bash .cross_compile.sh
|
||||
- name: Build
|
||||
env:
|
||||
GOOS: ${{ matrix.goos }}
|
||||
GOARCH: ${{ matrix.goarch }}
|
||||
CGO_ENABLED: "0"
|
||||
run: |
|
||||
mkdir -p dist
|
||||
BINARY="dist/deeplx_${GOOS}_${GOARCH}"
|
||||
if [ "${GOOS}" = "windows" ]; then
|
||||
BINARY="${BINARY}.exe"
|
||||
fi
|
||||
go build -trimpath -ldflags "-w -s" -o "${BINARY}" .
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: deeplx_${{ matrix.goos }}_${{ matrix.goarch }}
|
||||
path: dist/*
|
||||
if-no-files-found: error
|
||||
|
||||
Release:
|
||||
needs: Build
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: dist
|
||||
merge-multiple: true
|
||||
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
draft: false
|
||||
generate_release_notes: true
|
||||
files: |
|
||||
dist/*
|
||||
files: dist/*
|
||||
|
||||
@ -6,5 +6,8 @@ RUN CGO_ENABLED=0 go build -a -installsuffix cgo -o deeplx .
|
||||
|
||||
FROM alpine:latest
|
||||
WORKDIR /app
|
||||
COPY --from=builder /go/src/github.com/OwO-Network/DeepLX/deeplx /app/deeplx
|
||||
CMD ["/app/deeplx"]
|
||||
RUN addgroup -S deeplx && adduser -h /app -G deeplx -SH deeplx
|
||||
USER deeplx:deeplx
|
||||
COPY --from=builder --chown=deeplx:deeplx /go/src/github.com/OwO-Network/DeepLX/deeplx /app/deeplx
|
||||
EXPOSE 1188
|
||||
ENTRYPOINT ["/app/deeplx"]
|
||||
|
||||
15
install.sh
15
install.sh
@ -16,7 +16,20 @@ install_deeplx(){
|
||||
exit 1
|
||||
fi
|
||||
echo -e "DeepLX latest version: ${last_version}, Start install..."
|
||||
wget -q -N --no-check-certificate -O /usr/bin/deeplx https://github.com/OwO-Network/DeepLX/releases/download/${last_version}/deeplx_linux_amd64
|
||||
|
||||
arch=$(uname -m)
|
||||
case "${arch}" in
|
||||
x86_64 | amd64) file_arch="amd64" ;;
|
||||
aarch64 | arm64) file_arch="arm64" ;;
|
||||
i386 | i686) file_arch="386" ;;
|
||||
mips) file_arch="mips" ;;
|
||||
*)
|
||||
echo -e "${red}Unsupported architecture: ${arch}${plain}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
wget -q -N --no-check-certificate -O /usr/bin/deeplx https://github.com/OwO-Network/DeepLX/releases/download/${last_version}/deeplx_linux_${file_arch}
|
||||
|
||||
chmod +x /usr/bin/deeplx
|
||||
wget -q -N --no-check-certificate -O /etc/systemd/system/deeplx.service https://raw.githubusercontent.com/OwO-Network/DeepLX/main/deeplx.service
|
||||
|
||||
@ -108,7 +108,13 @@ func Router(cfg *Config) *gin.Engine {
|
||||
// Free API endpoint, No Pro Account required
|
||||
r.POST("/translate", authMiddleware(cfg), func(c *gin.Context) {
|
||||
req := PayloadFree{}
|
||||
c.BindJSON(&req)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{
|
||||
"code": http.StatusBadRequest,
|
||||
"message": "Invalid request payload",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
sourceLang := req.SourceLang
|
||||
targetLang := req.TargetLang
|
||||
@ -127,7 +133,12 @@ func Router(cfg *Config) *gin.Engine {
|
||||
|
||||
result, err := translate.TranslateByDeepLX(sourceLang, targetLang, translateText, tagHandling, proxyURL, "")
|
||||
if err != nil {
|
||||
log.Fatalf("Translation failed: %s", err)
|
||||
log.Printf("Translation failed: %s", err)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"code": http.StatusInternalServerError,
|
||||
"message": "Translation failed",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if result.Code == http.StatusOK {
|
||||
@ -152,7 +163,13 @@ func Router(cfg *Config) *gin.Engine {
|
||||
// Pro API endpoint, Pro Account required
|
||||
r.POST("/v1/translate", authMiddleware(cfg), func(c *gin.Context) {
|
||||
req := PayloadFree{}
|
||||
c.BindJSON(&req)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{
|
||||
"code": http.StatusBadRequest,
|
||||
"message": "Invalid request payload",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
sourceLang := req.SourceLang
|
||||
targetLang := req.TargetLang
|
||||
@ -191,7 +208,12 @@ func Router(cfg *Config) *gin.Engine {
|
||||
|
||||
result, err := translate.TranslateByDeepLX(sourceLang, targetLang, translateText, tagHandling, proxyURL, dlSession)
|
||||
if err != nil {
|
||||
log.Fatalf("Translation failed: %s", err)
|
||||
log.Printf("Translation failed: %s", err)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"code": http.StatusInternalServerError,
|
||||
"message": "Translation failed",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if result.Code == http.StatusOK {
|
||||
@ -243,7 +265,12 @@ func Router(cfg *Config) *gin.Engine {
|
||||
|
||||
result, err := translate.TranslateByDeepLX("", targetLang, translateText, "", proxyURL, "")
|
||||
if err != nil {
|
||||
log.Fatalf("Translation failed: %s", err)
|
||||
log.Printf("Translation failed: %s", err)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"code": http.StatusInternalServerError,
|
||||
"message": "Translation failed",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if result.Code == http.StatusOK {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user