Skip to content

Commit b34630c

Browse files
authored
chore(ci): add GitHub Actions (#12)
* Add basic Windows/Linux 386/x86_64 GitHub Actions * Add build-linux-arm64 target * Add build-linux-armv7 target * Add build-darwin-amd64 target * Add basic on push/pr build github action
1 parent 9aa70a0 commit b34630c

File tree

3 files changed

+186
-0
lines changed

3 files changed

+186
-0
lines changed

.github/workflows/build.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: build
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- name: Install dependencies
11+
run: |
12+
sudo apt -y update
13+
sudo apt -y install git golang liblzma-dev
14+
15+
- uses: actions/checkout@v2
16+
17+
- name: Build
18+
run: go build .

.github/workflows/goreleaser.yml

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: goreleaser
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
jobs:
9+
goreleaser:
10+
runs-on: ubuntu-latest
11+
container: fedora:latest
12+
13+
steps:
14+
- name: Install dependencies
15+
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}
16+
17+
- name: Setup cross compile environment for Linux ARMv7
18+
env:
19+
CC: arm-linux-gnueabihf-gcc
20+
CXX: arm-linux-gnueabihf-c++
21+
CFLAGS: -fPIC
22+
run: |
23+
dnf -y install 'dnf-command(copr)'
24+
dnf -y copr enable lantw44/arm-linux-gnueabihf-toolchain
25+
dnf -y install arm-linux-gnueabihf-{binutils,gcc,glibc}
26+
dnf -y install autoconf gettext-devel libtool po4a wget
27+
mkdir /linux-armv7-buildroot
28+
pushd /linux-armv7-buildroot
29+
wget https://tukaani.org/xz/xz-5.2.5.tar.gz
30+
tar -xvf xz-5.2.5.tar.gz
31+
pushd xz-5.2.5
32+
./autogen.sh
33+
./configure --host=armv7 --prefix=/linux-armv7-buildroot/sys-root
34+
make -j$(nproc) install
35+
popd
36+
popd
37+
38+
- name: Setup cross compile environment for Linux AArch64
39+
env:
40+
CC: aarch64-linux-gnu-gcc
41+
CXX: aarch64-linux-gnu-c++
42+
run: |
43+
dnf -y copr enable lantw44/aarch64-linux-gnu-toolchain
44+
dnf -y install aarch64-linux-gnu-{binutils,gcc,glibc}
45+
mkdir /linux-aarch64-buildroot
46+
pushd /linux-aarch64-buildroot
47+
wget https://tukaani.org/xz/xz-5.2.5.tar.gz
48+
tar -xvf xz-5.2.5.tar.gz
49+
pushd xz-5.2.5
50+
./autogen.sh
51+
./configure --host=aarch64 --prefix=/linux-aarch64-buildroot/sys-root
52+
make -j$(nproc) install
53+
popd
54+
popd
55+
56+
- id: osxcross-cache
57+
uses: actions/cache@v2
58+
with:
59+
path: /osxcross
60+
key: ${{ runner.os }}-osxcross
61+
62+
- name: Build osxcross
63+
if: steps.osxcross-cache.outputs.cache-hit != 'true'
64+
run: |
65+
git clone https://github.com/tpoechtrager/osxcross /osxcross
66+
pushd /osxcross
67+
dnf -y install clang llvm-devel libxml2-devel libuuid-devel openssl-devel bash patch libstdc++-static make cmake
68+
wget https://s3.dockerproject.org/darwin/v2/MacOSX10.11.sdk.tar.xz -O tarballs/MacOSX10.11.sdk.tar.xz
69+
UNATTENDED=1 ./build.sh
70+
popd
71+
72+
- name: Setup cross compile environment for Darwin AMD64
73+
env:
74+
CC: o64-clang
75+
CXX: o64-clang++
76+
run: |
77+
mkdir /darwin-amd64-buildroot
78+
pushd /darwin-amd64-buildroot
79+
wget https://tukaani.org/xz/xz-5.2.5.tar.gz
80+
tar -xvf xz-5.2.5.tar.gz
81+
pushd xz-5.2.5
82+
PATH=/osxcross/target/bin:$PATH ./autogen.sh
83+
PATH=/osxcross/target/bin:$PATH ./configure --host=x86_64-apple-darwin15 --prefix=/darwin-amd64-buildroot/sys-root --enable-shared=no
84+
PATH=/osxcross/target/bin:$PATH make -j$(nproc) install
85+
popd
86+
popd
87+
88+
- uses: actions/checkout@v2
89+
90+
- uses: goreleaser/goreleaser-action@v2
91+
with:
92+
version: latest
93+
args: release --rm-dist
94+
env:
95+
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'

.goreleaser.yml

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
env:
2+
- CGO_ENABLED=1
3+
builds:
4+
- id: build-windows-386
5+
env:
6+
- CC=i686-w64-mingw32-gcc
7+
- CXX=i686-w64-mingw32-g++
8+
goos:
9+
- windows
10+
goarch:
11+
- 386
12+
ldflags:
13+
- '-extldflags "-static -s -w"'
14+
- id: build-windows-amd64
15+
env:
16+
- CC=x86_64-w64-mingw32-gcc
17+
- CXX=x86_64-w64-mingw32-g++
18+
goos:
19+
- windows
20+
goarch:
21+
- amd64
22+
ldflags:
23+
- '-extldflags "-static -s -w"'
24+
- id: build-linux-386
25+
goos:
26+
- linux
27+
goarch:
28+
- 386
29+
ldflags:
30+
- '-extldflags "-static -s -w"'
31+
- id: build-linux-amd64
32+
goos:
33+
- linux
34+
goarch:
35+
- amd64
36+
ldflags:
37+
- '-extldflags "-static -s -w"'
38+
- id: build-linux-armv7
39+
env:
40+
- CC=arm-linux-gnueabihf-gcc
41+
- CXX=arm-linux-gnueabihf-c++
42+
- CGO_CFLAGS=-I/linux-armv7-buildroot/sys-root/include
43+
- CGO_LDFLAGS=-L/linux-armv7-buildroot/sys-root/lib
44+
goos:
45+
- linux
46+
goarch:
47+
- arm
48+
goarm:
49+
- 7
50+
ldflags:
51+
- '-extldflags "-static -s -w"'
52+
- id: build-linux-arm64
53+
env:
54+
- CC=aarch64-linux-gnu-gcc
55+
- CXX=aarch64-linux-gnu-c++
56+
- CGO_CFLAGS=-I/linux-aarch64-buildroot/sys-root/include
57+
- CGO_LDFLAGS=-L/linux-aarch64-buildroot/sys-root/lib
58+
goos:
59+
- linux
60+
goarch:
61+
- arm64
62+
ldflags:
63+
- '-extldflags "-static -s -w"'
64+
- id: build-darwin-amd64
65+
env:
66+
- CC=/osxcross/target/bin/o64-clang
67+
- CXX=/osxcross/target/bin/o64-clang++
68+
- CGO_CFLAGS=-I/darwin-amd64-buildroot/sys-root/include
69+
- CGO_LDFLAGS=-L/darwin-amd64-buildroot/sys-root/lib
70+
goos:
71+
- darwin
72+
goarch:
73+
- amd64

0 commit comments

Comments
 (0)