From acdbb326bc445d6437c34bd38e49c01838689957 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tiger=20Wang=20=28=E7=8E=8B=E8=B1=AB=29?= Date: Mon, 22 Aug 2022 17:22:27 -0400 Subject: [PATCH] change to static linking when building so older Linux distributions are supported (#5) --- .github/workflows/release.yml | 4 +-- .goreleaser.yaml | 58 ++++++++++++++++++++++++++++++----- 2 files changed, 52 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 32d0e66..f92f949 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,8 +18,8 @@ jobs: sudo apt update sudo apt-get --no-install-recommends --yes install \ libc6-dev-amd64-cross \ - gcc-11-aarch64-linux-gnu libc6-dev-arm64-cross \ - gcc-11-arm-linux-gnueabihf libc6-dev-armhf-cross + gcc-aarch64-linux-gnu libc6-dev-arm64-cross \ + gcc-arm-linux-gnueabihf libc6-dev-armhf-cross - name: Checkout uses: actions/checkout@v2 diff --git a/.goreleaser.yaml b/.goreleaser.yaml index d742a3b..a39f536 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -10,7 +10,14 @@ builds: binary: build/sysroot/usr/bin/casaos-user-service env: - CGO_ENABLED=1 - - CC=x86_64-linux-gnu-gcc-11 + - CC=x86_64-linux-gnu-gcc + ldflags: + - -s + - -w + - -extldflags "-static" + tags: + - musl + - netgo goos: - linux goarch: @@ -19,7 +26,14 @@ builds: binary: build/sysroot/usr/bin/casaos-user-service env: - CGO_ENABLED=1 - - CC=aarch64-linux-gnu-gcc-11 + - CC=aarch64-linux-gnu-gcc + ldflags: + - -s + - -w + - -extldflags "-static" + tags: + - musl + - netgo goos: - linux goarch: @@ -28,19 +42,33 @@ builds: binary: build/sysroot/usr/bin/casaos-user-service env: - CGO_ENABLED=1 - - CC=arm-linux-gnueabihf-gcc-11 + - CC=arm-linux-gnueabihf-gcc + ldflags: + - -s + - -w + - -extldflags "-static" + tags: + - musl + - netgo goos: - linux goarch: - arm goarm: - - 7 + - "7" - id: casaos-user-service-migration-tool-amd64 binary: build/sysroot/usr/bin/casaos-user-service-migration-tool main: ./cmd/migration-tool env: - CGO_ENABLED=1 - - CC=x86_64-linux-gnu-gcc-11 + - CC=x86_64-linux-gnu-gcc + ldflags: + - -s + - -w + - -extldflags "-static" + tags: + - musl + - netgo goos: - linux goarch: @@ -50,7 +78,14 @@ builds: main: ./cmd/migration-tool env: - CGO_ENABLED=1 - - CC=aarch64-linux-gnu-gcc-11 + - CC=aarch64-linux-gnu-gcc + ldflags: + - -s + - -w + - -extldflags "-static" + tags: + - musl + - netgo goos: - linux goarch: @@ -60,13 +95,20 @@ builds: main: ./cmd/migration-tool env: - CGO_ENABLED=1 - - CC=arm-linux-gnueabihf-gcc-11 + - CC=arm-linux-gnueabihf-gcc + ldflags: + - -s + - -w + - -extldflags "-static" + tags: + - musl + - netgo goos: - linux goarch: - arm goarm: - - 7 + - "7" archives: - name_template: "{{ .Os }}-{{ .Arch }}-{{ .ProjectName }}-v{{ .Version }}" id: casaos-user-service