Skip to content

Commit

Permalink
chore(ci): fixes/improvements + build Darwin/ARM64 (#15)
Browse files Browse the repository at this point in the history
* chore(ci): download macOS sdk in a separate job

* chore(ci): upgrade to fedora 34

Now that we have newer macOS SDK this is now possible.

* chore(ci): add build-darwin-arm64 target

* chore(ci): download xz source code from dnf

* chore(ci): handle osxcross cache properly
  • Loading branch information
luk1337 authored Apr 30, 2021
1 parent 9378850 commit 9ff1ed5
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 25 deletions.
97 changes: 72 additions & 25 deletions .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,55 @@ on:
- '*'

jobs:
macos-sdk:
runs-on: macos-latest
steps:
- id: osxcross-macos-sdk
uses: actions/cache@v2
with:
path: osxcross/tarballs
key: ${{ runner.os }}-osxcross-macos-sdk

- name: Package MacOSX SDK
if: steps.osxcross-macos-sdk.outputs.cache-hit != 'true'
run: |
git clone https://github.com/tpoechtrager/osxcross osxcross
pushd osxcross
XCODEDIR=/Applications/Xcode_12.4.app tools/gen_sdk_package.sh
mv MacOSX*.sdk.tar.xz tarballs/
popd
- uses: actions/upload-artifact@master
with:
name: osxcross-tarballs
path: osxcross/tarballs

goreleaser:
runs-on: ubuntu-latest
container: fedora:33
container: fedora:34
needs: macos-sdk

steps:
- name: Install dependencies
run: dnf -y install git golang mingw{32,64}-gcc{-c++,} mingw{32,64}-{winpthreads,xz-libs}-static glibc-{devel,static}.{i686,x86_64} xz-{devel,static}.{i686,x86_64}
run: |
dnf -y install autoconf bash clang cmake gettext-devel git glibc-{devel,static}.{i686,x86_64} golang libstdc++-static libtool libuuid-devel libxml2-devel llvm-devel make mingw{32,64}-{winpthreads,xz-libs}-static mingw{32,64}-gcc{-c++,} openssl-devel patch po4a xz-{devel,static}.{i686,x86_64}
dnf -y install 'dnf-command(download)'
dnf download --source xz-devel
rpm -ivh *.src.rpm
rm -f *.src.rpm
- name: Setup cross compile environment for Linux ARMv7
env:
CC: arm-linux-gnueabihf-gcc
CXX: arm-linux-gnueabihf-c++
CFLAGS: -fPIC
run: |
dnf -y install 'dnf-command(copr)'
dnf -y copr enable lantw44/arm-linux-gnueabihf-toolchain
dnf -y install arm-linux-gnueabihf-{binutils,gcc,glibc}
dnf -y install autoconf gettext-devel libtool po4a wget
mkdir /linux-armv7-buildroot
pushd /linux-armv7-buildroot
wget https://tukaani.org/xz/xz-5.2.5.tar.gz
tar -xvf xz-5.2.5.tar.gz
pushd xz-5.2.5
tar -xvf $HOME/rpmbuild/SOURCES/xz-*.tar.xz
pushd $(basename $HOME/rpmbuild/SOURCES/xz-*.tar.xz .tar.xz)
./autogen.sh
./configure --host=armv7 --prefix=/linux-armv7-buildroot/sys-root
make -j$(nproc) install
Expand All @@ -44,30 +70,37 @@ jobs:
dnf -y install aarch64-linux-gnu-{binutils,gcc,glibc}
mkdir /linux-aarch64-buildroot
pushd /linux-aarch64-buildroot
wget https://tukaani.org/xz/xz-5.2.5.tar.gz
tar -xvf xz-5.2.5.tar.gz
pushd xz-5.2.5
tar -xvf $HOME/rpmbuild/SOURCES/xz-*.tar.xz
pushd $(basename $HOME/rpmbuild/SOURCES/xz-*.tar.xz .tar.xz)
./autogen.sh
./configure --host=aarch64 --prefix=/linux-aarch64-buildroot/sys-root
make -j$(nproc) install
popd
popd
- id: osxcross-cache
- name: Download osxcross
run: git clone https://github.com/tpoechtrager/osxcross /osxcross

- id: osxcross-target
uses: actions/cache@v2
with:
path: /osxcross
key: ${{ runner.os }}-osxcross
path: /osxcross/target
key: ${{ runner.os }}-osxcross-target

- uses: actions/download-artifact@master
if: steps.osxcross-target.outputs.cache-hit != 'true'
with:
name: osxcross-tarballs
path: /osxcross/tarballs

- uses: geekyeggo/delete-artifact@v1
with:
name: osxcross-tarballs

- name: Build osxcross
if: steps.osxcross-cache.outputs.cache-hit != 'true'
run: |
git clone https://github.com/tpoechtrager/osxcross /osxcross
pushd /osxcross
dnf -y install clang llvm-devel libxml2-devel libuuid-devel openssl-devel bash patch libstdc++-static make cmake
wget https://s3.dockerproject.org/darwin/v2/MacOSX10.11.sdk.tar.xz -O tarballs/MacOSX10.11.sdk.tar.xz
UNATTENDED=1 ./build.sh
popd
if: steps.osxcross-target.outputs.cache-hit != 'true'
run: UNATTENDED=1 ./build.sh
working-directory: /osxcross

- name: Setup cross compile environment for Darwin AMD64
env:
Expand All @@ -76,11 +109,25 @@ jobs:
run: |
mkdir /darwin-amd64-buildroot
pushd /darwin-amd64-buildroot
wget https://tukaani.org/xz/xz-5.2.5.tar.gz
tar -xvf xz-5.2.5.tar.gz
pushd xz-5.2.5
tar -xvf $HOME/rpmbuild/SOURCES/xz-*.tar.xz
pushd $(basename $HOME/rpmbuild/SOURCES/xz-*.tar.xz .tar.xz)
PATH=/osxcross/target/bin:$PATH ./autogen.sh
PATH=/osxcross/target/bin:$PATH ./configure --host=x86_64-apple-darwin20.2 --prefix=/darwin-amd64-buildroot/sys-root --enable-shared=no
PATH=/osxcross/target/bin:$PATH make -j$(nproc) install
popd
popd
- name: Setup cross compile environment for Darwin AArch64
env:
CC: oa64-clang
CXX: oa64-clang++
run: |
mkdir /darwin-aarch64-buildroot
pushd /darwin-aarch64-buildroot
tar -xvf $HOME/rpmbuild/SOURCES/xz-*.tar.xz
pushd $(basename $HOME/rpmbuild/SOURCES/xz-*.tar.xz .tar.xz)
PATH=/osxcross/target/bin:$PATH ./autogen.sh
PATH=/osxcross/target/bin:$PATH ./configure --host=x86_64-apple-darwin15 --prefix=/darwin-amd64-buildroot/sys-root --enable-shared=no
PATH=/osxcross/target/bin:$PATH ./configure --host=aarch64-apple-darwin20.2 --prefix=/darwin-aarch64-buildroot/sys-root --enable-shared=no
PATH=/osxcross/target/bin:$PATH make -j$(nproc) install
popd
popd
Expand Down
11 changes: 11 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,14 @@ builds:
- darwin
goarch:
- amd64
- id: build-darwin-arm64
env:
- CC=oa64-clang
- CXX=oa64-clang++
- CGO_CFLAGS=-I/darwin-aarch64-buildroot/sys-root/include
- CGO_LDFLAGS=-L/darwin-aarch64-buildroot/sys-root/lib
- PATH=/osxcross/target/bin:$PATH
goos:
- darwin
goarch:
- arm64

0 comments on commit 9ff1ed5

Please sign in to comment.