diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5e419df..ac1a0f8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -62,6 +62,12 @@ jobs: TAG=${GITHUB_REF#refs/tags/Release_} echo "version=$TAG" >> $GITHUB_OUTPUT + - name: Install build tools (Linux) + if: runner.os == 'Linux' + run: | + sudo apt-get update -q + sudo apt-get install -y musl-tools + - name: Install build tools (macOS) if: runner.os == 'macOS' run: | @@ -74,8 +80,13 @@ jobs: GOOS: ${{ matrix.goos }} GOARCH: ${{ matrix.goarch }} VERSION: ${{ steps.get_version.outputs.version }} + CC: ${{ matrix.goos == 'linux' && 'musl-gcc' || '' }} run: | - make obitools + if [ "$GOOS" = "linux" ]; then + make LDFLAGS='-linkmode=external -extldflags=-static' obitools + else + make obitools + fi mkdir -p artifacts # Create a single tar.gz with all binaries for this platform tar -czf artifacts/obitools4_${VERSION}_${{ matrix.output_name }}.tar.gz -C build . diff --git a/Makefile b/Makefile index 1801300..8cd2a0c 100644 --- a/Makefile +++ b/Makefile @@ -10,8 +10,9 @@ BLUE := \033[0;34m NC := \033[0m GOFLAGS= +LDFLAGS= GOCMD=go -GOBUILD=$(GOCMD) build $(GOFLAGS) +GOBUILD=$(GOCMD) build $(GOFLAGS) $(if $(LDFLAGS),-ldflags='$(LDFLAGS)') GOGENERATE=$(GOCMD) generate GOCLEAN=$(GOCMD) clean GOTEST=$(GOCMD) test