mirror of
https://github.com/OwO-Network/DeepLX.git
synced 2026-06-11 23:38:51 +00:00
Compare commits
No commits in common. "main" and "v1.2.2" have entirely different histories.
51
.github/workflows/release.yaml
vendored
51
.github/workflows/release.yaml
vendored
@ -5,28 +5,11 @@ 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
|
||||||
|
|
||||||
@ -34,40 +17,12 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
go-version: "1.24.2"
|
go-version: "1.24.2"
|
||||||
|
|
||||||
- name: Build
|
- run: bash .cross_compile.sh
|
||||||
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: dist/*
|
files: |
|
||||||
|
dist/*
|
||||||
|
|||||||
@ -6,8 +6,5 @@ RUN CGO_ENABLED=0 go build -a -installsuffix cgo -o deeplx .
|
|||||||
|
|
||||||
FROM alpine:latest
|
FROM alpine:latest
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN addgroup -S deeplx && adduser -h /app -G deeplx -SH deeplx
|
COPY --from=builder /go/src/github.com/OwO-Network/DeepLX/deeplx /app/deeplx
|
||||||
USER deeplx:deeplx
|
CMD ["/app/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,20 +16,7 @@ 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,13 +108,7 @@ 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{}
|
||||||
if err := c.BindJSON(&req); err != nil {
|
c.BindJSON(&req)
|
||||||
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
|
||||||
@ -133,12 +127,7 @@ 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.Printf("Translation failed: %s", err)
|
log.Fatalf("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 {
|
||||||
@ -163,13 +152,7 @@ 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{}
|
||||||
if err := c.BindJSON(&req); err != nil {
|
c.BindJSON(&req)
|
||||||
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
|
||||||
@ -208,12 +191,7 @@ 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.Printf("Translation failed: %s", err)
|
log.Fatalf("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 {
|
||||||
@ -265,12 +243,7 @@ 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.Printf("Translation failed: %s", err)
|
log.Fatalf("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