From 3c44698e46db74f5016505f4a927ca01874d8fc0 Mon Sep 17 00:00:00 2001 From: Marco Franssen Date: Thu, 18 Dec 2025 16:54:59 +0100 Subject: [PATCH] ci: Add workflow --- .github/workflows/ci.yaml | 35 +++++++++++++++++++++++++++++++++++ Makefile | 29 +++++++++++++++++++++-------- 2 files changed, 56 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..6d71a5a --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,35 @@ +name: CI +on: + push: + paths: + - '.github/workflows/ci.yaml' + - 'go.*' + - '**/*.go' + - 'Dockerfile' + - 'Makefile' + pull_request: + paths: + - '.github/workflows/ci.yaml' + - 'go.*' + - '**/*.go' + - 'Dockerfile' + - 'Makefile' + +jobs: + build: + runs-on: ubuntu-24.04 + + permissions: + contents: read + + steps: + - name: Checkout + uses: actions/checkout@v6.0.1 + + - name: Set up Go + uses: actions/setup-go@v6.1.0 + with: + go-version-file: 'go.mod' + + - name: Build binary + run: make build diff --git a/Makefile b/Makefile index 5174101..f45a6c5 100644 --- a/Makefile +++ b/Makefile @@ -13,27 +13,40 @@ GOARM?="" BUILD_ENV=CGO_ENABLED=0 GOOS=linux GOARCH=$(GOARCH) GOARM=$(GOARM) BUILD_FLAGS="-s -w -extldflags \"-static\"" -.PHONY: all clean synology-csi-driver synocli test docker-build +.PHONY: all +all: build -all: synology-csi-driver +.PHONY: FORCE +FORCE: ; -synology-csi-driver: - @mkdir -p bin - $(BUILD_ENV) go build -v -ldflags $(BUILD_FLAGS) -o ./bin/synology-csi-driver ./ +.PHONY: build +build: bin/synology-csi-driver bin/synocli +bin: + @mkdir -p $@ + +bin/synology-csi-driver: bin FORCE + @echo "Compiling $@…" + @$(BUILD_ENV) go build -v -ldflags $(BUILD_FLAGS) -o $@ ./ + +.PHONY: docker-build docker-build: docker build -f Dockerfile -t $(IMAGE_TAG) . +.PHONY: docker-build-multiarch docker-build-multiarch: docker buildx build -t $(IMAGE_TAG) --platform linux/amd64,linux/arm/v7,linux/arm64 . --push -synocli: - @mkdir -p bin - $(BUILD_ENV) go build -v -ldflags $(BUILD_FLAGS) -o ./bin/synocli ./synocli +bin/synocli: bin FORCE + @echo "Compiling $@…" + @$(BUILD_ENV) go build -v -ldflags $(BUILD_FLAGS) -o $@ ./synocli +.PHONY: test test: go clean -testcache go test -v ./test/... + +.PHONY: clean clean: -rm -rf ./bin