Skip to content

Commit

Permalink
goreleaser
Browse files Browse the repository at this point in the history
  • Loading branch information
mosajjal committed Jan 1, 2023
1 parent b7bc2cc commit 2a190ff
Show file tree
Hide file tree
Showing 12 changed files with 106 additions and 415 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ jobs:
- name: Get dependencies
run: |
sudo apt install -y libpcap0.8-dev
go get -v ./...
go get -v ./cmd/dnsmonster
- name: Build
run: go build -v ./...
run: go build -v ./cmd/dnsmonster

- name: Test
run: go test -v ./...
run: go test -v ./cmd/dnsmonster

- name: generate sample config file
run: ./dnsmonster --writeConfig=config-sample.ini
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ docker-compose.yml
.vscode/*

.TODO.md

dist/
77 changes: 77 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com
before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
- freebsd
tags:
- nocgo
main: ./cmd/dnsmonster
archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'

# .goreleaser.yaml
nfpms:
# note that this is an array of nfpm configs
-
package_name: dnsmonster
homepage: https://dnsmonster.dev
maintainer: Ali Mosajjal <[email protected]>


description: |-
dnsmonster (built without CGO, no AFpacket support in this edition)
license: GPL-2.0

# Formats to be generated.
formats:
- apk
- deb
- rpm
- termux.deb # Since GoReleaser v1.11.
- archlinux # Since GoReleaser v1.13.

# Version Release.
release: 1

# Section.
section: default

# Priority.
priority: extra

# Makes a meta package - an empty package that contains only supporting
# files and dependencies.
# When set to `true`, the `builds` option is ignored.
# Defaults to false.
meta: true


contents:
# Basic file that applies to all packagers
- src: "./dist/{{ .PackageName }}_{{ .Os }}_{{ .Arch }}*/dnsmonster"
dst: /usr/bin/dnsmonster
2 changes: 1 addition & 1 deletion Dockerfile-crossplatform
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ RUN mkdir /${PROJECT} && mkdir ${OUTDIR}
COPY . /${PROJECT}
WORKDIR /${PROJECT}

env GOBUILD="go build -ldflags=-s -tags ${GOTAG} -o ${OUTDIR}/${PROJECT}_${GOTAG}" ./...
env GOBUILD="go build -ldflags=-s -tags ${GOTAG} -o ${OUTDIR}/${PROJECT}_${GOTAG}" ./cmd/dnsmonster

# Linux
RUN echo "Building Linux binaries"
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile-release
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ RUN git clone https://${REPO}.git /opt/dnsmonster --depth 1 \
ENV CGO_ENABLED=1
ENV GOOS=windows
ENV GOARCH=amd64
RUN sh -c 'cd /opt/dnsmonster && go build -o /tmp/dnsmonster-windows-amd64.exe' ./...
RUN sh -c 'cd /opt/dnsmonster && go build -o /tmp/dnsmonster-windows-amd64.exe' ./cmd/dmsmonster

WORKDIR /opt/dnsmonster

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ sudo docker run --rm -it --net=host --cap-add NET_RAW --cap-add NET_ADMIN --name
### Build manually

- with `libpcap`:
Make sure you have `go`, `libpcap-devel` and `linux-headers` packages installed. The name of the packages might differ based on your distribution. After this, simply clone the repository and run `go build ./...`
Make sure you have `go`, `libpcap-devel` and `linux-headers` packages installed. The name of the packages might differ based on your distribution. After this, simply clone the repository and run `go build ./cmd/dnsmonster`

```sh
git clone https://github.com/mosajjal/dnsmonster --depth 1 /tmp/dnsmonster
cd /tmp/dnsmonster
go get
go build -o dnsmonster ./...
go build -o dnsmonster ./cmd/dnsmonster
```

- without `libpcap`:
Expand All @@ -102,7 +102,7 @@ go build -o dnsmonster ./...
git clone https://github.com/mosajjal/dnsmonster --depth 1 /tmp/dnsmonster
cd /tmp/dnsmonster
go get
go build -o dnsmonster -tags nolibpcap ./...
go build -o dnsmonster -tags nolibpcap ./cmd/dnsmonster
```

The above build also works on ARMv7 (RPi4) and AArch64.
Expand Down Expand Up @@ -143,7 +143,7 @@ Much the same as Linux and Windows, make sure you have `git`, `libpcap` and `go`
git clone https://github.com/mosajjal/dnsmonster --depth 1 /tmp/dnsmonster
cd /tmp/dnsmonster
go get
go build -o dnsmonster ./...
go build -o dnsmonster ./cmd/dnsmonster
```

# Architecture
Expand Down
4 changes: 2 additions & 2 deletions docs/content/en/docs/Getting started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Check out the configuration section to understand the provided command line argu
git clone https://github.com/mosajjal/dnsmonster --depth 1 /tmp/dnsmonster
cd /tmp/dnsmonster
go get
go build -o dnsmonster ./...
go build -o dnsmonster ./cmd/dnsmonster
```

- without `libpcap`:
Expand All @@ -47,7 +47,7 @@ go build -o dnsmonster ./...
git clone https://github.com/mosajjal/dnsmonster --depth 1 /tmp/dnsmonster
cd /tmp/dnsmonster
go get
go build -o dnsmonster -tags nolibpcap ./...
go build -o dnsmonster -tags nolibpcap ./cmd/dnsmonster
```

The above build also works on ARMv7 (RPi4) and AArch64.
Expand Down
Loading

0 comments on commit 2a190ff

Please sign in to comment.