add upx for binary compression

pull/806/head^2
ginuerzh 2025-07-26 16:43:49 +08:00
parent d448628fea
commit b593fdb952
4 changed files with 72 additions and 3 deletions

View File

@ -23,6 +23,10 @@ jobs:
with: with:
go-version: '1.24' go-version: '1.24'
cache: true cache: true
- name: Install UPX
uses: crazy-max/ghaction-upx@v3
with:
install-only: true
# More assembly might be required: Docker logins, GPG, etc. It all depends # More assembly might be required: Docker logins, GPG, etc. It all depends
# on your needs. # on your needs.
- uses: goreleaser/goreleaser-action@v6 - uses: goreleaser/goreleaser-action@v6

View File

@ -3,7 +3,7 @@ name: Trigger nightly build
on: on:
schedule: schedule:
# * is a special character in YAML, so you have to quote this string # * is a special character in YAML, so you have to quote this string
- cron: '30 15 * * *' - cron: '00 15 * * *'
workflow_dispatch: workflow_dispatch:
jobs: jobs:

View File

@ -38,6 +38,67 @@ builds:
ldflags: ldflags:
- "-s -w -X 'main.version={{ .Tag }}'" - "-s -w -X 'main.version={{ .Tag }}'"
upx:
- # Whether to enable it or not.
#
# Templates: allowed.
enabled: true
# Filter by build ID.
# ids: [build1, build2]
# Filter by GOOS.
goos: [linux]
# Filter by GOARCH.
goarch: [arm, arm64, amd64]
# Filter by GOARM.
# goarm: [8]
# Filter by GOAMD64.
# goamd64: [v1]
# Compress argument.
# Valid options are from '1' (faster) to '9' (better), and 'best'.
compress: best
# Whether to try LZMA (slower).
lzma: true
# Whether to try all methods and filters (slow).
brute: true
- # Whether to enable it or not.
#
# Templates: allowed.
enabled: true
# Filter by build ID.
# ids: [build1, build2]
# Filter by GOOS.
goos: [windows]
# Filter by GOARCH.
goarch: [amd64]
# Filter by GOARM.
# goarm: [8]
# Filter by GOAMD64.
# goamd64: [v1]
# Compress argument.
# Valid options are from '1' (faster) to '9' (better), and 'best'.
compress: best
# Whether to try LZMA (slower).
lzma: true
# Whether to try all methods and filters (slow).
brute: true
archives: archives:
- format: tar.gz - format: tar.gz
# use zip for windows archives # use zip for windows archives

View File

@ -2,6 +2,9 @@ FROM --platform=$BUILDPLATFORM tonistiigi/xx:1.6.1 AS xx
FROM --platform=$BUILDPLATFORM golang:1.24-alpine3.22 AS builder FROM --platform=$BUILDPLATFORM golang:1.24-alpine3.22 AS builder
# add upx for binary compression
RUN apk add --no-cache upx || echo "upx not found"
COPY --from=xx / / COPY --from=xx / /
ARG TARGETPLATFORM ARG TARGETPLATFORM
@ -17,8 +20,9 @@ WORKDIR /app
COPY . . COPY . .
RUN cd cmd/gost && \ RUN cd cmd/gost && \
xx-go build && \ xx-go build -ldflags "-s -w" && \
xx-verify gost xx-verify gost && \
{ upx --best gost || true; }
FROM alpine:3.22 FROM alpine:3.22