Skip to content

Commit

Permalink
attempt xbuild
Browse files Browse the repository at this point in the history
  • Loading branch information
hoshsadiq committed Aug 12, 2024
1 parent 6afc7e6 commit cf5da8c
Show file tree
Hide file tree
Showing 5 changed files with 181 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .github/actions/mike-test-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ inputs:
tag:
description: 'Tag to upload artifacts to.'
required: true

outputs:
hashes:
description: sha256sum hashes of built artifacts
Expand All @@ -32,6 +33,14 @@ runs:
shell: bash
run: |
echo $DOCKER_TOKEN | docker login --username $DOCKER_USERNAME --password-stdin
- uses: goto-bus-stop/[email protected]
with:
version: 0.14.0

- run: sudo apt-get install gcc-aarch64-linux-gnu gcc-arm-linux-gnueabihf
shell: bash

- name: Run Goreleaser
uses: goreleaser/goreleaser-action@v5
with:
Expand Down
60 changes: 60 additions & 0 deletions .goreleaser.grcross.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
env:
- CGO_ENABLED=1
builds:
- &default_config
id: ldcli-linux_amd64
binary: ldcli
goos:
- linux
goarch:
- amd64
ldflags:
- -s
- -w
env:
- CC=x86_64-linux-gnu-gcc
- CXX=x86_64-linux-gnu-g++
- <<: *default_config
id: ldcli-linux_arm64
goarch:
- arm64
env:
- CC=aarch64-linux-gnu-gcc
- CXX=aarch64-linux-gnu-gcc
- <<: *default_config
id: ldcli-linux_armhf
goarm:
- "7"
goarch:
- arm
env:
- CC=arm-linux-gnueabihf-gcc
- CXX=arm-linux-gnueabihf-g++
- <<: *default_config
id: ldcli-darwin_amd64
goarch:
- amd64
env:
- CC=o64-clang
- CXX=o64-clang++
- <<: *default_config
id: ldcli-darwin_arm64
goarch:
- arm64
env:
- CC=oa64-clang
- CXX=oa64-clang++
- <<: *default_config
id: ldcli-windows_amd64
goarch:
- amd64
env:
- CC=x86_64-w64-mingw32-gcc
- CXX=x86_64-w64-mingw32-g++
- <<: *default_config
id: ldcli-windows_arm64
goarch:
- arm64
env:
- CC=/llvm-mingw/bin/aarch64-w64-mingw32-gcc
- CXX=/llvm-mingw/bin/aarch64-w64-mingw32-g++
73 changes: 73 additions & 0 deletions .goreleaser.zig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
env:
- CGO_ENABLED=1
builds:
- &default_config
id: ldcli-linux_amd64
binary: ldcli
goos:
- linux
goarch:
- amd64
ldflags:
- -s
- -w
- -extldflags=-static
flags:
- -trimpath
tags:
- osusergo
- netgo
- sqlite_omit_load_extension
env:
- CC=zig cc -target x86_64-linux-musl
- CXX=zig c++ -target x86_64-linux-musl
- <<: *default_config
id: ldcli-linux_arm64
goarch:
- arm64
env:
- CC=zig cc -target aarch64-linux-musl
- CXX=zig c++ -target aarch64-linux-musl
- <<: *default_config
id: ldcli-linux_armhf
goarm:
- "7"
goarch:
- arm
env:
- CC=zig cc -target arm-linux-musl
- CXX=zig c++ -target arm-linux-musl
- <<: *default_config
id: ldcli-darwin_amd64
goarch:
- amd64
flags:
- -trimpath
- -buildmode=pie
env:
- CC=zig cc -target x86_64-macos-none
- CXX=zig c++ -target x86_64-macos-none
- <<: *default_config
id: ldcli-darwin_arm64
goarch:
- arm64
flags:
- -trimpath
- -buildmode=pie
env:
- CC=zig cc -target aarch64-macos-none
- CXX=zig c++ -target aarch64-macos-none
- <<: *default_config
id: ldcli-windows_amd64
goarch:
- amd64
env:
- CC=zig cc -target x86_64-windows-gnu
- CXX=zig c++ -target x86_64-windows-gnu
- <<: *default_config
id: ldcli-windows_arm64
goarch:
- arm64
env:
- CC=zig cc -target aarch64-windows-gnu
- CXX=zig c++ -target aarch64-windows-gnu
14 changes: 14 additions & 0 deletions scripts/gr-cross-runner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

set -eu

# based on https://github.com/goreleaser/goreleaser-cross
docker image inspect grcross-xbuilder &>/dev/null || docker build -t grcross-xbuilder -f - . <<EOF
FROM ghcr.io/goreleaser/goreleaser-cross:latest
RUN set -eux; \
apt update; \
apt-get install libc6-dev libc6-dev-i386 musl-tools musl-dev -y
EOF

exec docker run -it --rm -v "$PWD:$PWD" -w "$PWD" grcross-xbuilder build --snapshot --clean --config .goreleaser.grcross.yaml
25 changes: 25 additions & 0 deletions scripts/zig-runner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

set -eu

# based on https://github.com/goreleaser/goreleaser-example-zig-cgo/tree/master
docker image inspect zig-xbuilder &>/dev/null || docker build -t zig-xbuilder -f - . <<EOF
FROM ghcr.io/goreleaser/goreleaser-cross:latest AS gr_cross
FROM golang:1.22-bullseye
ENV PATH="$PATH:/usr/local/share/zig-linux-x86_64-0.14.0-dev.1021+fc2924080:/go/bin:/usr/local/go/bin"
COPY --from=gr_cross /usr/local/osxcross/SDK/MacOSX12.0.sdk/System/Library/Frameworks /host/Frameworks
RUN set -eux; \
apt update; \
apt install xz-utils bash -y; \
wget -q -O- https://ziglang.org/builds/zig-linux-x86_64-0.14.0-dev.1021+fc2924080.tar.xz | tar -Jxf - -C /usr/local/share/; \
zig version; \
curl -sfL -o- https://github.com/goreleaser/goreleaser/releases/download/v2.1.0/goreleaser_Linux_x86_64.tar.gz | tar -zxf - -C /usr/local/bin/; \
go version; \
goreleaser --version
EOF

exec docker run -v "$PWD:$PWD:z" -w "$PWD" -it --rm --entrypoint /usr/local/bin/goreleaser zig-xbuilder build --snapshot --clean --config .goreleaser.zig.yaml

0 comments on commit cf5da8c

Please sign in to comment.