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:
go-version: '1.24'
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
# on your needs.
- uses: goreleaser/goreleaser-action@v6

View File

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

View File

@ -38,6 +38,67 @@ builds:
ldflags:
- "-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:
- format: tar.gz
# 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
# add upx for binary compression
RUN apk add --no-cache upx || echo "upx not found"
COPY --from=xx / /
ARG TARGETPLATFORM
@ -17,8 +20,9 @@ WORKDIR /app
COPY . .
RUN cd cmd/gost && \
xx-go build && \
xx-verify gost
xx-go build -ldflags "-s -w" && \
xx-verify gost && \
{ upx --best gost || true; }
FROM alpine:3.22