Skip to content

Commit 206bd30

Browse files
committed
github ci/cd stuff
1 parent 397bbb9 commit 206bd30

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

.github/workflows/build.yml

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Build
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
release:
8+
name: Release
9+
runs-on: ubuntu-latest
10+
outputs:
11+
upload_url: ${{steps.release.outputs.upload_url}}
12+
steps:
13+
- uses: actions/create-release@v1
14+
id: release
15+
env:
16+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17+
with:
18+
tag_name: tag-${{ github.sha }}
19+
release_name: ${{ github.sha }}
20+
21+
build:
22+
name: Build
23+
runs-on: ubuntu-latest
24+
needs: release
25+
strategy:
26+
matrix:
27+
arch: [ x86_64, aarch64 ]
28+
steps:
29+
- uses: actions/checkout@v3
30+
- run: sudo sh -c 'apt update && apt install qemu-user-static'
31+
32+
# build in alpine chroot to allow for the binary to be static
33+
- run: wget -O rootfs.tgz https://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/${{ matrix.arch }}/alpine-minirootfs-3.18.3-${{ matrix.arch }}.tar.gz
34+
- run: mkdir rootfs
35+
- run: sudo tar -C rootfs -xf rootfs.tgz
36+
- run: sudo mkdir rootfs/src
37+
- run: sudo mount -o bind . rootfs/src
38+
- run: sudo cp $(which qemu-${{ matrix.arch }}-static) rootfs/
39+
- run: printf 'nameserver 1.1.1.1\n' | sudo tee rootfs/etc/resolv.conf
40+
- run: sudo chroot rootfs /qemu-${{ matrix.arch }}-static /bin/sh /src/static.sh
41+
42+
- run: cp rootfs/src/dns-tools .
43+
- run: zip release.zip dns-tools
44+
45+
- uses: actions/upload-release-asset@v1
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
with:
49+
upload_url: ${{ needs.release.outputs.upload_url }}
50+
asset_path: release.zip
51+
asset_name: release_${{ matrix.arch }}.zip
52+
asset_content_type: application/zip

static.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
3+
apk add alpine-sdk go sqlite-dev
4+
go build -C src -tags netgo,sqlite_omit_load_extension -trimpath -ldflags="-s -w -extldflags=-static" -buildmode=pie

0 commit comments

Comments
 (0)