Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Statically link Linux binary with musl #893

Merged
merged 1 commit into from
Sep 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Statically link Linux binary with musl
  • Loading branch information
twpayne committed Sep 28, 2020
commit c04022bb56ebef768170fdbd6b51306c456e7d2d
8 changes: 7 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ jobs:
test-release:
runs-on: ubuntu-latest
steps:
- name: Install musl
run: |
sudo apt install -y musl-tools
- name: Set up Go
uses: actions/setup-go@v2
with:
Expand All @@ -62,7 +65,7 @@ jobs:
- name: Test release
run: |
# verify that version information is embedded correctly
./dist/chezmoi-cgo_linux_amd64/chezmoi --version | tee /dev/stderr | grep -q "chezmoi version v"
file ./dist/chezmoi-cgo_linux_amd64/chezmoi | tee /dev/stderr | grep -q "statically linked"
./dist/chezmoi-cgo_linux_amd64/chezmoi --version | tee /dev/stderr | grep -q "chezmoi version v"
./dist/chezmoi-nocgo_linux_386/chezmoi --version | tee /dev/stderr | grep -q "chezmoi version v"
generate:
Expand Down Expand Up @@ -103,6 +106,9 @@ jobs:
- test-release
runs-on: ubuntu-latest
steps:
- name: Install musl
run: |
sudo apt install -y musl-tools
- name: Set up Go
uses: actions/setup-go@v2
with:
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/bin/gofumports
/bin/golangci-lint
/chezmoi
/chezmoi.exe
/chezmoi*
/dist
10 changes: 10 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,21 @@ builds:
- id: chezmoi-cgo
binary: chezmoi
env:
- CC=/usr/bin/musl-gcc
- CGO_ENABLED=1
goos:
- linux
goarch:
- amd64
ldflags:
- '-s'
- '-w'
- '-X main.version={{.Version}}'
- '-X main.commit={{.Commit}}'
- '-X main.date={{.Date}}'
- '-X main.builtBy=goreleaser'
- '-linkmode external'
- '--extldflags "-static"'
- id: chezmoi-nocgo
binary: chezmoi
env:
Expand Down