diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 00000000..ad20bcd2 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,23 @@ +name: CI + +on: + push: + branches: [master] + pull_request: + types: [opened, synchronize] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version-file: go.mod + # - run: go mod tidy && git diff -s --exit-code go.sum + - run: make test + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: make build-image diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 00000000..bc7491b5 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,20 @@ +name: Release + +on: + push: + tags: ["v*"] + +jobs: + run: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version-file: go.mod + - uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - run: make push-image diff --git a/Dockerfile b/Dockerfile index 50582d78..dca00966 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ RUN apk update && apk add git && apk add curl WORKDIR /go/src/github.com/planetlabs/draino COPY . . -RUN go build -o /draino ./cmd/draino +RUN CGO_ENABLED=0 go build -o /draino ./cmd/draino FROM alpine:3.11 diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..749ba6a7 --- /dev/null +++ b/Makefile @@ -0,0 +1,21 @@ +IMG_REG ?= ghcr.io/pfnet/draino +IMG_TAG ?= $(shell git describe --always --tags --dirty) + +.PHONY: build +build: + go build -o draino ./cmd/draino + +.PHONY: test +test: + go vet ./... + go test -v ./... + +.PHONY: build-image +build-image: + docker build --progress plain -t $(IMG_REG):$(IMG_TAG) . + +.PHONY: push-image +push-image: build-image + docker tag $(IMG_REG):$(IMG_TAG) $(IMG_REG):latest + docker push $(IMG_REG):$(IMG_TAG) + docker push $(IMG_REG):latest