Skip to content

Commit b5b5056

Browse files
committed
ready for v1.0.1
1 parent bfdce93 commit b5b5056

File tree

5 files changed

+166
-177
lines changed

5 files changed

+166
-177
lines changed
Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
1-
name: Publish cross-compile binaries on Release
2-
on:
1+
name: Publish binaries on Release
2+
on:
33
release:
44
types: [created]
55

66
jobs:
7-
build:
8-
name: Build
9-
runs-on: ubuntu-22.04
7+
releases-matrix:
8+
name: Release Go Binary
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
# build and publish in parallel: linux/386, linux/amd64, windows/386, windows/amd64, darwin/386, darwin/amd64
13+
goos: [linux, windows, darwin, freebsd, openbsd]
14+
goarch: [amd64, arm64, arm]
15+
exclude:
16+
- goarch: "arm"
17+
goos: windows
18+
- goarch: "arm"
19+
goos: darwin
1020
steps:
11-
12-
- name: Check out code into the Go module directory
13-
uses: actions/checkout@v4
14-
15-
- name: Get dependencies
16-
run: |
17-
docker build -t myrepo:latest -f Dockerfile-crossplatform .
18-
id=$(docker create myrepo:latest)
19-
docker cp $id:/ /tmp/bin
20-
21-
- name: Upload Linux binary to release
22-
uses: svenstaro/upload-release-action@v2
23-
with:
24-
repo_token: ${{ secrets.GITHUB_TOKEN }}
25-
file: /tmp/bin/*.bin
26-
file_glob: true
27-
tag: ${{ github.ref }}
28-
overwrite: true
21+
- uses: actions/checkout@v4
22+
- uses: wangyoucao577/go-release-action@master
23+
env:
24+
CGO_ENABLED: 0 # support alpine
25+
with:
26+
github_token: ${{ secrets.GITHUB_TOKEN }}
27+
goos: ${{ matrix.goos }}
28+
goarch: ${{ matrix.goarch }}
29+
project_path: "./cmd/dnsmonster"
30+
ldflags: "-s -w"
31+
build_flags: "-v -tags nolibpcap"

.github/workflows/release.yml

Lines changed: 50 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Publish binaries on Release
2-
on:
2+
on:
33
release:
44
types: [created]
55

@@ -8,62 +8,61 @@ jobs:
88
name: Build
99
runs-on: ubuntu-22.04
1010
steps:
11+
- name: Check out code into the Go module directory
12+
uses: actions/checkout@v4
1113

12-
- name: Check out code into the Go module directory
13-
uses: actions/checkout@v4
14+
- name: Get dependencies
15+
run: |
16+
docker build -t myrepo:latest -f Dockerfile-release .
17+
id=$(docker create myrepo:latest)
18+
docker cp $id:/tmp/dnsmonster-linux-amd64.bin /tmp/dnsmonster-linux-amd64.bin
19+
docker cp $id:/tmp/dnsmonster-windows-amd64.exe /tmp/dnsmonster-windows-amd64.exe
20+
docker cp $id:/tmp/dnsmonster-latest.rpm /tmp/dnsmonster-latest.rpm
21+
docker cp $id:/tmp/dnsmonster-latest.deb /tmp/dnsmonster-latest.deb
22+
strip --strip-all /tmp/dnsmonster-linux-amd64.bin
23+
tar czf /tmp/dnsmonster-linux-amd64.bin.tar.gz -C /tmp/ dnsmonster-linux-amd64.bin
1424
15-
- name: Get dependencies
16-
run: |
17-
docker build -t myrepo:latest -f Dockerfile-release .
18-
id=$(docker create myrepo:latest)
19-
docker cp $id:/tmp/dnsmonster-linux-amd64.bin /tmp/dnsmonster-linux-amd64.bin
20-
docker cp $id:/tmp/dnsmonster-windows-amd64.exe /tmp/dnsmonster-windows-amd64.exe
21-
docker cp $id:/tmp/dnsmonster-latest.rpm /tmp/dnsmonster-latest.rpm
22-
docker cp $id:/tmp/dnsmonster-latest.deb /tmp/dnsmonster-latest.deb
23-
strip --strip-all /tmp/dnsmonster-linux-amd64.bin
24-
tar czf /tmp/dnsmonster-linux-amd64.bin.tar.gz -C /tmp/ dnsmonster-linux-amd64.bin
25+
- name: Upload Linux binary to release
26+
uses: svenstaro/upload-release-action@v2
27+
with:
28+
repo_token: ${{ secrets.GITHUB_TOKEN }}
29+
file: /tmp/dnsmonster-linux-amd64.bin.tar.gz
30+
asset_name: dnsmonster-musl-static-stripped-amd64.tar.gz
31+
tag: ${{ github.ref }}
32+
overwrite: true
33+
body: ""
2534

26-
- name: Upload Linux binary to release
27-
uses: svenstaro/upload-release-action@v2
28-
with:
29-
repo_token: ${{ secrets.GITHUB_TOKEN }}
30-
file: /tmp/dnsmonster-linux-amd64.bin.tar.gz
31-
asset_name: dnsmonster-musl-static-stripped-amd64.tar.gz
32-
tag: ${{ github.ref }}
33-
overwrite: true
34-
body: ""
35+
- name: Upload windows binary to release
36+
uses: svenstaro/upload-release-action@v2
37+
with:
38+
repo_token: ${{ secrets.GITHUB_TOKEN }}
39+
file: /tmp/dnsmonster-windows-amd64.exe
40+
asset_name: dnsmonster-windows-amd64.exe
41+
tag: ${{ github.ref }}
42+
overwrite: true
43+
body: ""
3544

36-
- name: Upload windows binary to release
37-
uses: svenstaro/upload-release-action@v2
38-
with:
39-
repo_token: ${{ secrets.GITHUB_TOKEN }}
40-
file: /tmp/dnsmonster-windows-amd64.exe
41-
asset_name: dnsmonster-windows-amd64.exe
42-
tag: ${{ github.ref }}
43-
overwrite: true
44-
body: ""
45+
- name: Upload rpm to release
46+
uses: svenstaro/upload-release-action@v2
47+
with:
48+
repo_token: ${{ secrets.GITHUB_TOKEN }}
49+
file: /tmp/dnsmonster-latest.rpm
50+
asset_name: dnsmonster-centos-rhel-ami-x86_64.rpm
51+
tag: ${{ github.ref }}
52+
overwrite: true
53+
body: ""
4554

46-
- name: Upload rpm to release
47-
uses: svenstaro/upload-release-action@v2
48-
with:
49-
repo_token: ${{ secrets.GITHUB_TOKEN }}
50-
file: /tmp/dnsmonster-latest.rpm
51-
asset_name: dnsmonster-centos-rhel-ami-x86_64.rpm
52-
tag: ${{ github.ref }}
53-
overwrite: true
54-
body: ""
55-
56-
- name: Upload deb to release
57-
uses: svenstaro/upload-release-action@v2
58-
with:
59-
repo_token: ${{ secrets.GITHUB_TOKEN }}
60-
file: /tmp/dnsmonster-latest.deb
61-
asset_name: dnsmonster-debian-ubuntu-x86_64.deb
62-
tag: ${{ github.ref }}
63-
overwrite: true
64-
body: ""
55+
- name: Upload deb to release
56+
uses: svenstaro/upload-release-action@v2
57+
with:
58+
repo_token: ${{ secrets.GITHUB_TOKEN }}
59+
file: /tmp/dnsmonster-latest.deb
60+
asset_name: dnsmonster-debian-ubuntu-x86_64.deb
61+
tag: ${{ github.ref }}
62+
overwrite: true
63+
body: ""
6564

6665
# - uses: actions/upload-artifact@v2
6766
# with:
6867
# name: dnsmonster-latest.deb
69-
# path: /tmp/dnsmonster*.deb
68+
# path: /tmp/dnsmonster*.deb

Dockerfile-crossplatform

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
11
FROM alpine:edge
2-
LABEL maintainer "Ali Mosajjal <[email protected]>"
2+
LABEL maintainer="Ali Mosajjal <[email protected]>"
33

44
RUN apk add --no-cache git go zig file --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing/
55

66
ARG PROJECT=dnsmonster
77
ARG GOTAG=nolibpcap
88
ARG GOLDFLAGS='-s -w'
9-
# OUTDIR is also used in the second layer for copying the folder.
10-
ARG OUTDIR="/tmp/bins"
9+
# OUTDIR is also used in the second layer for copying the folder.
10+
ARG OUTDIR="/tmp/bins"
1111
RUN mkdir /${PROJECT} && mkdir ${OUTDIR}
1212
COPY . /${PROJECT}
1313
WORKDIR /${PROJECT}
1414

15-
env GOBUILD="go build -ldflags=-s -tags ${GOTAG} -o ${OUTDIR}/${PROJECT}_${GOTAG}"
16-
env BASEDIR="./cmd/dnsmonster"
15+
ENV GOBUILD="go build -ldflags=-s -tags ${GOTAG} -o ${OUTDIR}/${PROJECT}_${GOTAG}"
16+
ENV BASEDIR="./cmd/dnsmonster"
1717

1818
# Linux
1919
RUN echo "Building Linux binaries"
2020
RUN export GOOS=linux && export CGO_ENABLED=1 && \
2121
export GOARCH=amd64 && CC="zig cc -target x86_64-${GOOS}-musl" ${GOBUILD}_${GOOS}_${GOARCH}.bin ${BASEDIR} && \
22-
export GOARCH=386 && CC="zig cc -target i386-${GOOS}-musl" ${GOBUILD}_${GOOS}_${GOARCH}.bin ${BASEDIR} && \
2322
export GOARCH=arm && CC="zig cc -target arm-${GOOS}-musleabihf" ${GOBUILD}_${GOOS}_${GOARCH}.bin ${BASEDIR} && \
2423
export GOARCH=arm64 && CC="zig cc -target aarch64-${GOOS}-musl" ${GOBUILD}_${GOOS}_${GOARCH}.bin ${BASEDIR} && \
2524
export GOARCH=riscv64 && CC="zig cc -target riscv64-${GOOS}-musl" ${GOBUILD}_${GOOS}_${GOARCH}.bin ${BASEDIR}
@@ -29,7 +28,6 @@ RUN export GOOS=linux && export CGO_ENABLED=1 && \
2928
RUN echo "Building Windows binaries"
3029
RUN export GOOS=windows && export CGO_ENABLED=1 && \
3130
export GOARCH=amd64 && CC="zig cc -target x86_64-${GOOS}-gnu" ${GOBUILD}_${GOOS}_${GOARCH}.bin ${BASEDIR} && \
32-
export GOARCH=386 && CC="zig cc -target i386-${GOOS}-gnu" ${GOBUILD}_${GOOS}_${GOARCH}.bin ${BASEDIR} && \
3331
export GOARCH=arm && CC="zig cc -target arm-${GOOS}-gnu" ${GOBUILD}_${GOOS}_${GOARCH}.bin ${BASEDIR} && \
3432
export GOARCH=arm64 && CC="zig cc -target aarch64-${GOOS}-gnu" ${GOBUILD}_${GOOS}_${GOARCH}.bin ${BASEDIR}
3533

@@ -45,26 +43,23 @@ RUN export GOOS=freebsd && export CGO_ENABLED=0 && \
4543
export GOARCH=arm64 && ${GOBUILD}_${GOOS}_${GOARCH}.bin ${BASEDIR} && \
4644
export GOARCH=amd64 && ${GOBUILD}_${GOOS}_${GOARCH}.bin ${BASEDIR} && \
4745
export GOARCH=arm && ${GOBUILD}_${GOOS}_${GOARCH}.bin ${BASEDIR} && \
48-
export GOARCH=386 && ${GOBUILD}_${GOOS}_${GOARCH}.bin ${BASEDIR}
4946

50-
# NetBSD
51-
RUN echo "Building NetBSD binaries"
47+
# NetBSD
48+
RUN echo "Building NetBSD binaries"
5249
RUN export GOOS=netbsd && export CGO_ENABLED=0 && \
5350
export GOARCH=arm64 && ${GOBUILD}_${GOOS}_${GOARCH}.bin ${BASEDIR} && \
5451
export GOARCH=amd64 && ${GOBUILD}_${GOOS}_${GOARCH}.bin ${BASEDIR} && \
5552
export GOARCH=arm && ${GOBUILD}_${GOOS}_${GOARCH}.bin ${BASEDIR} && \
56-
export GOARCH=386 && ${GOBUILD}_${GOOS}_${GOARCH}.bin ${BASEDIR}
5753

58-
# OpenBSD
59-
RUN echo "Building OpenBSD binaries"
54+
# OpenBSD
55+
RUN echo "Building OpenBSD binaries"
6056
RUN export GOOS=openbsd && export CGO_ENABLED=0 && \
6157
export GOARCH=arm64 && ${GOBUILD}_${GOOS}_${GOARCH}.bin ${BASEDIR} && \
6258
export GOARCH=amd64 && ${GOBUILD}_${GOOS}_${GOARCH}.bin ${BASEDIR} && \
6359
export GOARCH=arm && ${GOBUILD}_${GOOS}_${GOARCH}.bin ${BASEDIR} && \
64-
export GOARCH=386 && ${GOBUILD}_${GOOS}_${GOARCH}.bin ${BASEDIR}
6560

66-
# Android
67-
RUN echo "Building Android binaries"
61+
# Android
62+
RUN echo "Building Android binaries"
6863
RUN export GOOS=android && export CGO_ENABLED=0 && \
6964
export GOARCH=arm64 && ${GOBUILD}_${GOOS}_${GOARCH}.bin ${BASEDIR}
7065

@@ -75,4 +70,4 @@ RUN export GOOS=dragonfly && export CGO_ENABLED=0 && \
7570

7671
FROM scratch
7772
COPY --from=0 /tmp/bins/*.bin /
78-
ENTRYPOINT ["/dnsmonster"]
73+
ENTRYPOINT ["/dnsmonster"]

0 commit comments

Comments
 (0)