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 |
53
.github/workflows/release.yaml
vendored
53
.github/workflows/release.yaml
vendored
@ -5,11 +5,28 @@ on:
|
|||||||
pull_request:
|
pull_request:
|
||||||
|
|
||||||
name: Release
|
name: Release
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
Build:
|
Build:
|
||||||
if: startsWith(github.ref, 'refs/tags/v')
|
if: startsWith(github.ref, 'refs/tags/v')
|
||||||
runs-on: ubuntu-latest
|
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:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
@ -17,12 +34,40 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
go-version: "1.24.2"
|
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
|
- name: Release
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
with:
|
with:
|
||||||
draft: false
|
draft: false
|
||||||
generate_release_notes: true
|
generate_release_notes: true
|
||||||
files: |
|
files: dist/*
|
||||||
dist/*
|
|
||||||
|
|||||||
@ -6,5 +6,8 @@ RUN CGO_ENABLED=0 go build -a -installsuffix cgo -o deeplx .
|
|||||||
|
|
||||||
FROM alpine:latest
|
FROM alpine:latest
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=builder /go/src/github.com/OwO-Network/DeepLX/deeplx /app/deeplx
|
RUN addgroup -S deeplx && adduser -h /app -G deeplx -SH deeplx
|
||||||
CMD ["/app/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
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo -e "DeepLX latest version: ${last_version}, Start install..."
|
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
|
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
|
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
|
// Free API endpoint, No Pro Account required
|
||||||
r.POST("/translate", authMiddleware(cfg), func(c *gin.Context) {
|
r.POST("/translate", authMiddleware(cfg), func(c *gin.Context) {
|
||||||
req := PayloadFree{}
|
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
|
sourceLang := req.SourceLang
|
||||||
targetLang := req.TargetLang
|
targetLang := req.TargetLang
|
||||||
@ -127,7 +133,12 @@ func Router(cfg *Config) *gin.Engine {
|
|||||||
|
|
||||||
result, err := translate.TranslateByDeepLX(sourceLang, targetLang, translateText, tagHandling, proxyURL, "")
|
result, err := translate.TranslateByDeepLX(sourceLang, targetLang, translateText, tagHandling, proxyURL, "")
|
||||||
if err != nil {
|
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 {
|
if result.Code == http.StatusOK {
|
||||||
@ -152,7 +163,13 @@ func Router(cfg *Config) *gin.Engine {
|
|||||||
// Pro API endpoint, Pro Account required
|
// Pro API endpoint, Pro Account required
|
||||||
r.POST("/v1/translate", authMiddleware(cfg), func(c *gin.Context) {
|
r.POST("/v1/translate", authMiddleware(cfg), func(c *gin.Context) {
|
||||||
req := PayloadFree{}
|
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
|
sourceLang := req.SourceLang
|
||||||
targetLang := req.TargetLang
|
targetLang := req.TargetLang
|
||||||
@ -191,7 +208,12 @@ func Router(cfg *Config) *gin.Engine {
|
|||||||
|
|
||||||
result, err := translate.TranslateByDeepLX(sourceLang, targetLang, translateText, tagHandling, proxyURL, dlSession)
|
result, err := translate.TranslateByDeepLX(sourceLang, targetLang, translateText, tagHandling, proxyURL, dlSession)
|
||||||
if err != nil {
|
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 {
|
if result.Code == http.StatusOK {
|
||||||
@ -243,7 +265,12 @@ func Router(cfg *Config) *gin.Engine {
|
|||||||
|
|
||||||
result, err := translate.TranslateByDeepLX("", targetLang, translateText, "", proxyURL, "")
|
result, err := translate.TranslateByDeepLX("", targetLang, translateText, "", proxyURL, "")
|
||||||
if err != nil {
|
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 {
|
if result.Code == http.StatusOK {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user