Skip to content

Commit

Permalink
add upx as part of building step to shrink the size of binary files (
Browse files Browse the repository at this point in the history
  • Loading branch information
tigerinus authored Dec 29, 2022
1 parent 324aebf commit bc6e73d
Show file tree
Hide file tree
Showing 6 changed files with 178 additions and 135 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
run: |
sudo apt update
sudo apt-get --no-install-recommends --yes install \
libc6-dev-amd64-cross \
upx libc6-dev-amd64-cross \
gcc-aarch64-linux-gnu libc6-dev-arm64-cross \
gcc-arm-linux-gnueabihf libc6-dev-armhf-cross
-
Expand Down
30 changes: 30 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ before:
builds:
- id: casaos-message-bus-amd64
binary: build/sysroot/usr/bin/casaos-message-bus
hooks:
post:
- upx --best --lzma -v --no-progress "{{ .Path }}"
env:
- CC=x86_64-linux-gnu-gcc
ldflags:
- -X main.commit={{.Commit}}
- -X main.date={{.Date}}
- -s
- -w
- -extldflags "-static"
Expand All @@ -26,9 +31,14 @@ builds:
- amd64
- id: casaos-message-bus-arm64
binary: build/sysroot/usr/bin/casaos-message-bus
hooks:
post:
- upx --best --lzma -v --no-progress "{{ .Path }}"
env:
- CC=aarch64-linux-gnu-gcc
ldflags:
- -X main.commit={{.Commit}}
- -X main.date={{.Date}}
- -s
- -w
- -extldflags "-static"
Expand All @@ -42,9 +52,14 @@ builds:
- arm64
- id: casaos-message-bus-arm-7
binary: build/sysroot/usr/bin/casaos-message-bus
hooks:
post:
- upx --best --lzma -v --no-progress "{{ .Path }}"
env:
- CC=arm-linux-gnueabihf-gcc
ldflags:
- -X main.commit={{.Commit}}
- -X main.date={{.Date}}
- -s
- -w
- -extldflags "-static"
Expand All @@ -60,10 +75,15 @@ builds:
- "7"
- id: casaos-message-bus-migration-tool-amd64
binary: build/sysroot/usr/bin/casaos-message-bus-migration-tool
hooks:
post:
- upx --best --lzma -v --no-progress "{{ .Path }}"
main: ./cmd/migration-tool
env:
- CC=x86_64-linux-gnu-gcc
ldflags:
- -X main.commit={{.Commit}}
- -X main.date={{.Date}}
- -s
- -w
- -extldflags "-static"
Expand All @@ -77,10 +97,15 @@ builds:
- amd64
- id: casaos-message-bus-migration-tool-arm64
binary: build/sysroot/usr/bin/casaos-message-bus-migration-tool
hooks:
post:
- upx --best --lzma -v --no-progress "{{ .Path }}"
main: ./cmd/migration-tool
env:
- CC=aarch64-linux-gnu-gcc
ldflags:
- -X main.commit={{.Commit}}
- -X main.date={{.Date}}
- -s
- -w
- -extldflags "-static"
Expand All @@ -94,10 +119,15 @@ builds:
- arm64
- id: casaos-message-bus-migration-tool-arm-7
binary: build/sysroot/usr/bin/casaos-message-bus-migration-tool
hooks:
post:
- upx --best --lzma -v --no-progress "{{ .Path }}"
main: ./cmd/migration-tool
env:
- CC=arm-linux-gnueabihf-gcc
ldflags:
- -X main.commit={{.Commit}}
- -X main.date={{.Date}}
- -s
- -w
- -extldflags "-static"
Expand Down
10 changes: 9 additions & 1 deletion cmd/migration-tool/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ const (
//go:embedded ../../build/sysroot/etc/casaos/message-bus.conf.sample
// var _messageBusConfigFileSample string

var _logger *Logger
var (
commit = "private build"
date = "private build"

_logger *Logger
)

// var _status *version.GlobalMigrationStatus

Expand All @@ -36,6 +41,9 @@ func main() {
os.Exit(0)
}

println("git commit:", commit)
println("build date:", date)

_logger = NewLogger()

if os.Getuid() != 0 {
Expand Down
75 changes: 38 additions & 37 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,83 +3,84 @@ module github.com/IceWhaleTech/CasaOS-MessageBus
go 1.19

require (
github.com/IceWhaleTech/CasaOS-Common v0.4.0-alpha1
github.com/glebarez/sqlite v1.5.0
github.com/IceWhaleTech/CasaOS-Common v0.4.0
github.com/glebarez/sqlite v1.6.0
github.com/gobwas/ws v1.1.0
github.com/json-iterator/go v1.1.12
go.uber.org/goleak v1.1.11
gorm.io/gorm v1.24.1
go.uber.org/goleak v1.2.0
gorm.io/gorm v1.24.2
gotest.tools v2.2.0+incompatible
)

require (
github.com/andybalholm/brotli v1.0.1 // indirect
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
github.com/andybalholm/brotli v1.0.4 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/gin-gonic/gin v1.8.1 // indirect
github.com/glebarez/go-sqlite v1.19.1 // indirect
github.com/gin-gonic/gin v1.8.2 // indirect
github.com/glebarez/go-sqlite v1.20.0 // indirect
github.com/go-playground/locales v0.14.0 // indirect
github.com/go-playground/universal-translator v0.18.0 // indirect
github.com/go-playground/validator/v10 v10.11.1 // indirect
github.com/gobwas/httphead v0.1.0 // indirect
github.com/gobwas/pool v0.2.1 // indirect
github.com/goccy/go-json v0.9.11 // indirect
github.com/godbus/dbus/v5 v5.0.4 // indirect
github.com/goccy/go-json v0.10.0 // indirect
github.com/godbus/dbus/v5 v5.1.0 // indirect
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
github.com/golang-jwt/jwt/v4 v4.4.2 // indirect
github.com/golang/snappy v0.0.2 // indirect
github.com/google/go-cmp v0.5.8 // indirect
github.com/golang-jwt/jwt/v4 v4.4.3 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/klauspost/compress v1.11.4 // indirect
github.com/klauspost/compress v1.15.13 // indirect
github.com/klauspost/pgzip v1.2.5 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/mholt/archiver/v3 v3.5.1 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/nwaples/rardecode v1.1.0 // indirect
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
github.com/pierrec/lz4/v4 v4.1.2 // indirect
github.com/nwaples/rardecode v1.1.3 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/pierrec/lz4/v4 v4.1.17 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect
github.com/ugorji/go/codec v1.2.7 // indirect
github.com/ulikunitz/xz v0.5.9 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20220927061507-ef77025ab5aa // indirect
github.com/ugorji/go/codec v1.2.8 // indirect
github.com/ulikunitz/xz v0.5.11 // indirect
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
golang.org/x/time v0.0.0-20220411224347-583f2d630306 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
modernc.org/libc v1.19.0 // indirect
modernc.org/libc v1.22.2 // indirect
modernc.org/mathutil v1.5.0 // indirect
modernc.org/memory v1.4.0 // indirect
modernc.org/sqlite v1.19.1 // indirect
modernc.org/memory v1.5.0 // indirect
modernc.org/sqlite v1.20.1 // indirect
)

require (
github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf
github.com/deepmap/oapi-codegen v1.12.2
github.com/getkin/kin-openapi v0.107.0
github.com/deepmap/oapi-codegen v1.12.4
github.com/getkin/kin-openapi v0.112.0
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/swag v0.21.1 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/google/uuid v1.3.0
github.com/invopop/yaml v0.1.0 // indirect
github.com/invopop/yaml v0.2.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/labstack/echo/v4 v4.9.1
github.com/labstack/echo/v4 v4.10.0
github.com/labstack/gommon v0.4.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.21.0
golang.org/x/crypto v0.1.0 // indirect
golang.org/x/net v0.1.0 // indirect
golang.org/x/sys v0.1.0 // indirect
golang.org/x/text v0.4.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
go.uber.org/zap v1.24.0
golang.org/x/crypto v0.4.0 // indirect
golang.org/x/net v0.4.0 // indirect
golang.org/x/sys v0.3.0 // indirect
golang.org/x/text v0.5.0 // indirect
gopkg.in/ini.v1 v1.67.0
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand Down
Loading

0 comments on commit bc6e73d

Please sign in to comment.