diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..12fabe1 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,31 @@ +name: Publish binaries on Release +on: + release: + types: [created] + +jobs: + build: + name: Build + runs-on: ubuntu-20.04 + steps: + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Get dependencies + run: | + docker build -t myrepo:latest -f Dockerfile . + id=$(docker create myrepo:latest) + docker cp $id:/tcpshark /tmp/tcpshark.bin + strip --strip-all /tmp/tcpshark.bin + + - name: Upload Linux binary to release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: /tmp/tcpshark.bin + asset_name: tcpshark-static-musl-linux.bin + tag: ${{ github.ref }} + overwrite: true + body: "" + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a6f8d30 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM alpine:edge +LABEL maintainer "Ali Mosajjal " + +SHELL ["/bin/ash", "-c"] + +RUN apk add --no-cache libcap-static libpcap-dev linux-headers git go file rpm --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing/ + +ENV DST="/tmp/tcpshark/" +ENV REPO="github.com/mosajjal/tcpshark" +RUN git clone https://${REPO}.git ${DST} --depth 1 \ + && cd ${DST} \ + && go build --ldflags "-L /usr/lib/libcap.a -linkmode external -extldflags \"-static\"" -o ${DST}/tcpshark + + +FROM scratch +COPY --from=0 /tmp/tcpshark/tcpshark /tcpshark +ENTRYPOINT ["/tcpshark"]