Compare commits

..

No commits in common. "main" and "v1.2.2" have entirely different histories.
main ... v1.2.2

4 changed files with 12 additions and 100 deletions

View File

@ -5,28 +5,11 @@ 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
@ -34,40 +17,12 @@ jobs:
with:
go-version: "1.24.2"
- 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
- run: bash .cross_compile.sh
- name: Release
uses: softprops/action-gh-release@v1
with:
draft: false
generate_release_notes: true
files: dist/*
files: |
dist/*

View File

@ -6,8 +6,5 @@ RUN CGO_ENABLED=0 go build -a -installsuffix cgo -o deeplx .
FROM alpine:latest
WORKDIR /app
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"]
COPY --from=builder /go/src/github.com/OwO-Network/DeepLX/deeplx /app/deeplx
CMD ["/app/deeplx"]

View File

@ -16,20 +16,7 @@ install_deeplx(){
exit 1
fi
echo -e "DeepLX latest version: ${last_version}, Start install..."
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}
wget -q -N --no-check-certificate -O /usr/bin/deeplx https://github.com/OwO-Network/DeepLX/releases/download/${last_version}/deeplx_linux_amd64
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

View File

@ -108,13 +108,7 @@ func Router(cfg *Config) *gin.Engine {
// Free API endpoint, No Pro Account required
r.POST("/translate", authMiddleware(cfg), func(c *gin.Context) {
req := PayloadFree{}
if err := c.BindJSON(&req); err != nil {
c.JSON(http.StatusBadRequest, gin.H{
"code": http.StatusBadRequest,
"message": "Invalid request payload",
})
return
}
c.BindJSON(&req)
sourceLang := req.SourceLang
targetLang := req.TargetLang
@ -133,12 +127,7 @@ func Router(cfg *Config) *gin.Engine {
result, err := translate.TranslateByDeepLX(sourceLang, targetLang, translateText, tagHandling, proxyURL, "")
if err != nil {
log.Printf("Translation failed: %s", err)
c.JSON(http.StatusInternalServerError, gin.H{
"code": http.StatusInternalServerError,
"message": "Translation failed",
})
return
log.Fatalf("Translation failed: %s", err)
}
if result.Code == http.StatusOK {
@ -163,13 +152,7 @@ func Router(cfg *Config) *gin.Engine {
// Pro API endpoint, Pro Account required
r.POST("/v1/translate", authMiddleware(cfg), func(c *gin.Context) {
req := PayloadFree{}
if err := c.BindJSON(&req); err != nil {
c.JSON(http.StatusBadRequest, gin.H{
"code": http.StatusBadRequest,
"message": "Invalid request payload",
})
return
}
c.BindJSON(&req)
sourceLang := req.SourceLang
targetLang := req.TargetLang
@ -208,12 +191,7 @@ func Router(cfg *Config) *gin.Engine {
result, err := translate.TranslateByDeepLX(sourceLang, targetLang, translateText, tagHandling, proxyURL, dlSession)
if err != nil {
log.Printf("Translation failed: %s", err)
c.JSON(http.StatusInternalServerError, gin.H{
"code": http.StatusInternalServerError,
"message": "Translation failed",
})
return
log.Fatalf("Translation failed: %s", err)
}
if result.Code == http.StatusOK {
@ -265,12 +243,7 @@ func Router(cfg *Config) *gin.Engine {
result, err := translate.TranslateByDeepLX("", targetLang, translateText, "", proxyURL, "")
if err != nil {
log.Printf("Translation failed: %s", err)
c.JSON(http.StatusInternalServerError, gin.H{
"code": http.StatusInternalServerError,
"message": "Translation failed",
})
return
log.Fatalf("Translation failed: %s", err)
}
if result.Code == http.StatusOK {