From 0a2544e5480923039e67408f0ad15582f8e0c495 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Mon, 11 Dec 2023 13:50:20 +0100 Subject: [PATCH] wip --- .github/workflows/build.yml | 41 +++++++++++++++++++++++++++++++++++++ Dockerfile | 8 ++++++++ Makefile | 14 +++++++++++-- 3 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 Dockerfile diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..7de9aff --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,41 @@ +name: Build +on: + pull_request: + push: + +permissions: + contents: read + packages: write + +jobs: + build-server: + runs-on: ubuntu-latest + name: Build + steps: + + - uses: actions/checkout@v4 + + - name: Install Go + uses: actions/setup-go@v4 + with: + go-version: ~1.21.5 + check-latest: true + + - name: Build binary + run: | + make build + + - name: Log in to the GitHub container registry + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: ghcr.io/kastelo/syncthing-autoacceptd:latest diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f8b6ebe --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +FROM gcr.io/distroless/static:nonroot +LABEL org.opencontainers.image.title "Syncthing Auto Accept Daemon" +LABEL org.opencontainers.image.url "https://kastelo.net/" +LABEL org.opencontainers.image.vendor "Kastelo AB" +LABEL org.opencontainers.image.source "https://github.com/kastelo/syncthing-autoacceptd" +ARG TARGETARCH +COPY bin/syncthing-autoacceptd-linux-$TARGETARCH /bin/syncthing-autoacceptd +ENTRYPOINT ["/bin/syncthing-autoacceptd"] diff --git a/Makefile b/Makefile index 0a362a1..f12c4ad 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,19 @@ ldflags:="-X kastelo.dev/syncthing-autoacceptd/internal/build.GitVersion=$(shell git describe)" +.PHONY: install +install: + @go install -v -ldflags $(ldflags) ./cmd/autoacceptd + .PHONY: build -build: proto +build: proto build-linux-amd64 build-linux-arm64 + +build-linux-amd64: + @mkdir -p bin + @GOOS=linux GOARCH=amd64 go build -v -ldflags $(ldflags) -o bin/syncthing-autoacceptd-linux-amd64 ./cmd/autoacceptd + +build-linux-arm64: @mkdir -p bin - @go build -v -ldflags $(ldflags) -o bin/syncthing-autoacceptd ./cmd/autoacceptd + @GOOS=linux GOARCH=arm64 go build -v -ldflags $(ldflags) -o bin/syncthing-autoacceptd-linux-arm64 ./cmd/autoacceptd .PHONY: proto proto: