diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..34369df --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,38 @@ +name: goreleaser + +on: + push: + tags: + - "v*" + +jobs: + goreleaser: + runs-on: ubuntu-latest + environment: build + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.18 + + - name: Login to Docker Registry + uses: docker/login-action@v1 + with: + username: ${{ secrets.GEDOCKER_USERNAME }} + password: ${{ secrets.GEDOCKER_PASSWORD }} + + - name: Prepare Dependencies + run: | + make dist + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + version: latest + args: --parallelism 1 --rm-dist --skip-validate + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index b7d5ce7..fa2736d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ .idea .env dev/dev-data + +dist/ diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..8481cf8 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,31 @@ +builds: + - env: + - CGO_ENABLED=0 + goos: + - linux + goarch: + - amd64 + main: ./cmd + ldflags: + - -s -w + +archives: + - format: tar.gz + files: + - LICENSE + - config.toml + - queries.sql + - migrations/* + +dockers: + - goos: linux + goarch: amd64 + ids: + - cic-dw + image_templates: + - "docker.grassecon.net/cic-dw/cic-dw:latest" + - "docker.grassecon.net/cic-dw/cic-dw:{{ .Tag }}" + dockerfile: Dockerfile + extra_files: + - config.toml + - queries.sql diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..493ecf5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM debian:11-slim + +RUN set -x && apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ + ca-certificates && \ + rm -rf /var/lib/apt/lists/* + +WORKDIR /cic-dw + +COPY cic-dw . +COPY config.toml . +COPY queries.sql . + +CMD ["./cic-dw"] diff --git a/go.mod b/go.mod index 5285c31..9ef3efe 100644 --- a/go.mod +++ b/go.mod @@ -11,6 +11,7 @@ require ( github.com/lmittmann/w3 v0.7.0 github.com/nleof/goyesql v1.0.1 github.com/rs/zerolog v1.26.1 + golang.org/x/sys v0.0.0-20220502124256-b6088ccd6cba ) require ( @@ -47,7 +48,6 @@ require ( github.com/tklauser/go-sysconf v0.3.5 // indirect github.com/tklauser/numcpus v0.2.2 // indirect golang.org/x/crypto v0.0.0-20220427172511-eb4f295cb31f // indirect - golang.org/x/sys v0.0.0-20220502124256-b6088ccd6cba // indirect golang.org/x/text v0.3.7 // indirect golang.org/x/time v0.0.0-20220411224347-583f2d630306 // indirect google.golang.org/protobuf v1.28.0 // indirect