Skip to content

Commit

Permalink
Re-testing multiarch build with glibc instead of musl
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlovelltroy committed Oct 28, 2024
1 parent e17332d commit 1777995
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 81 deletions.
39 changes: 7 additions & 32 deletions .github/workflows/PRBuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,27 @@ on:


jobs:
build:
prbuild:
runs-on: ubuntu-latest
steps:
- name: Install musl and cross-compilation tools
- name: Install cross-compilation tools
run: |
sudo apt-get update
sudo apt-get install -y musl-tools musl musl-dev
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
sudo apt-get install -y gcc-x86-64-linux-gnu g++-x86-64-linux-gnu
sudo apt-get install -y qemu-user-static
sudo apt-get install -y binfmt-support
sudo update-binfmts --enable qemu-aarch64
sudo update-binfmts --display qemu-aarch64
sudo update-binfmts --enable qemu-arm
sudo update-binfmts --display qemu-arm
- name: Set up Go 1.23
uses: actions/setup-go@v5
with:
go-version: 1.23
go-version: stable
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Docker Login
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout
uses: actions/checkout@v4
with:
fetch-tags: 1
fetch-depth: 1

# Set environment variables required by GoReleaser
- name: Set build environment variables
run: |
Expand All @@ -52,7 +38,6 @@ jobs:
echo "GO_VERSION=$(go version | awk '{print $3}')" >> $GITHUB_ENV
echo "BUILD_USER=$(whoami)" >> $GITHUB_ENV
echo "CGO_ENABLED=1" >> $GITHUB_ENV
echo "CC=musl-gcc" >> $GITHUB_ENV
- name: Build with goreleaser
uses: goreleaser/goreleaser-action@v6
Expand All @@ -61,14 +46,4 @@ jobs:
with:
version: '~> v2'
args: build --clean --snapshot
id: goreleaser
- name: Verify binaries are static
run: |
for binary in dist/*amd64_v1/*; do
if file "$binary" | grep -q "statically linked"; then
echo "$binary is statically linked"
else
echo "$binary is not statically linked"
fi
done
id: goreleaser
34 changes: 13 additions & 21 deletions .github/workflows/Release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,46 +11,38 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Install musl and cross-compilation tools
- name: Install cross-compilation tools
run: |
sudo apt-get update
sudo apt-get install -y musl-tools musl musl-dev
sudo apt-get install -y gcc-aarch64-linux-gnu
sudo apt-get install -y g++-aarch64-linux-gnu
sudo apt-get install -y gcc-x86-64-linux-gnu
sudo apt-get install -y g++-x86-64-linux-gnu
sudo apt-get install -y qemu-user-static
sudo apt-get install -y binfmt-support
sudo update-binfmts --enable qemu-aarch64
sudo update-binfmts --display qemu-aarch64
sudo update-binfmts --enable qemu-arm
sudo update-binfmts --display qemu-arm
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
- name: Set up Go 1.23
uses: actions/setup-go@v5
with:
go-version: 1.23
go-version: stable
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Docker Login
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout
uses: actions/checkout@v4
with:
fetch-tags: 1
fetch-depth: 1

# Set environment variables required by GoReleaser
- name: Set build environment variables
run: |
echo "GIT_STATE=$(if git diff-index --quiet HEAD --; then echo 'clean'; else echo 'dirty'; fi)" >> $GITHUB_ENV
echo "BUILD_HOST=$(hostname)" >> $GITHUB_ENV
echo "GO_VERSION=$(go version | awk '{print $3}')" >> $GITHUB_ENV
echo "BUILD_USER=$(whoami)" >> $GITHUB_ENV
echo "CGO_ENABLED=1" >> $GITHUB_ENV
- name: Docker Login
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Release with goreleaser
uses: goreleaser/goreleaser-action@v6
env:
Expand Down
50 changes: 23 additions & 27 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com
version: 2

project_name: smd
before:
hooks:
Expand All @@ -25,22 +21,22 @@ builds:
-X main.GitState={{ .Env.GIT_STATE }} \
-X main.BuildHost={{ .Env.BUILD_HOST }} \
-X main.GoVersion={{ .Env.GO_VERSION }} \
-X main.BuildUser={{ .Env.BUILD_USER }} \
-extldflags '-static'"
-X main.BuildUser={{ .Env.BUILD_USER }} "
goos:
- linux
- darwin
goarch:
- amd64
- arm64
tags:
- musl
env:
- CGO_ENABLED=1
asmflags:
- "GOARCH=arm64:CC=gcc-aarch64-linux-gnu"
- "GOARCH=amd64:CC=musl-gcc"

- >-
CC={{- if eq .Os "linux" -}}
{{- if eq .Arch "amd64" -}}gcc{{- else -}}aarch64-linux-gnu-gcc{{- end -}}
{{- else if eq .Os "darwin" -}}
{{- if eq .Arch "amd64" -}}clang{{- else -}}clang -target arm64-apple-macos11{{- end -}}
{{- end }}
- id: smd-init
main: ./cmd/smd-init/
binary: smd-init
Expand All @@ -53,21 +49,22 @@ builds:
-X main.GitState={{ .Env.GIT_STATE }} \
-X main.BuildHost={{ .Env.BUILD_HOST }} \
-X main.GoVersion={{ .Env.GO_VERSION }} \
-X main.BuildUser={{ .Env.BUILD_USER }} \
-extldflags '-static'"
-X main.BuildUser={{ .Env.BUILD_USER }} "
goos:
- linux
- darwin
goarch:
- amd64
- arm64
tags:
- musl
env:
- CGO_ENABLED=1
asmflags:
- "GOARCH=arm64:CC=gcc-aarch64-linux-gnu"
- "GOARCH=amd64:CC=musl-gcc"
- >-
CC={{- if eq .Os "linux" -}}
{{- if eq .Arch "amd64" -}}gcc{{- else -}}aarch64-linux-gnu-gcc{{- end -}}
{{- else if eq .Os "darwin" -}}
{{- if eq .Arch "amd64" -}}clang{{- else -}}clang -target arm64-apple-macos11{{- end -}}
{{- end }}
- id: smd-loader
main: ./cmd/smd-loader/
binary: smd-loader
Expand All @@ -80,21 +77,21 @@ builds:
-X main.GitState={{ .Env.GIT_STATE }} \
-X main.BuildHost={{ .Env.BUILD_HOST }} \
-X main.GoVersion={{ .Env.GO_VERSION }} \
-X main.BuildUser={{ .Env.BUILD_USER }} \
-extldflags '-static'"
-X main.BuildUser={{ .Env.BUILD_USER }} "
goos:
- linux
- darwin
goarch:
- amd64
- arm64
tags:
- musl
env:
- CGO_ENABLED=1
asmflags:
- "GOARCH=arm64:CC=gcc-aarch64-linux-gnu"
- "GOARCH=amd64:CC=musl-gcc"
- >-
CC={{- if eq .Os "linux" -}}
{{- if eq .Arch "amd64" -}}gcc{{- else -}}aarch64-linux-gnu-gcc{{- end -}}
{{- else if eq .Os "darwin" -}}
{{- if eq .Arch "amd64" -}}clang{{- else -}}clang -target arm64-apple-macos11{{- end -}}
{{- end }}
dockers:
- image_templates:
Expand Down Expand Up @@ -183,7 +180,6 @@ changelog:
- '^docs:'
- '^test:'


# The lines beneath this are called `modelines`. See `:help modeline`
# Feel free to remove those if you don't want/use them.
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM alpine:3.20
FROM chainguard/wolfi-base:latest

RUN apk add --no-cache tini

Expand Down

0 comments on commit 1777995

Please sign in to comment.