diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml new file mode 100644 index 00000000..dd5d092a --- /dev/null +++ b/.github/dependabot.yaml @@ -0,0 +1,24 @@ +version: 2 +updates: +- package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + commit-message: + prefix: ":seedling:" + labels: + - "ok-to-test" +- package-ecosystem: "gomod" + directory: "/" + schedule: + interval: "weekly" + commit-message: + prefix: ":seedling:" + labels: + - "ok-to-test" + ignore: + # Ignore k8s and its transitives modules as they are upgraded manually + # together with controller-runtime. + - dependency-name: "k8s.io/*" + - dependency-name: "go.etcd.io/*" + - dependency-name: "google.golang.org/grpc" diff --git a/.github/workflows/container-image.yaml b/.github/workflows/container-image.yaml new file mode 100644 index 00000000..1bfe6de1 --- /dev/null +++ b/.github/workflows/container-image.yaml @@ -0,0 +1,36 @@ +name: container-image + +on: + push: + branches: + - main + +jobs: + main-image: + name: build "main" image + runs-on: "ubuntu-latest" + steps: + - uses: actions/checkout@v3 + + - name: Install Go + uses: actions/setup-go@v4 + with: + go-version: "^1.18" + + - name: Create Licenses Report + run: | + make licenses-report + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2.0.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v4.0.0 + with: + context: . + push: true + tags: ghcr.io/telekom/cluster-api-ipam-provider-in-cluster:main diff --git a/.github/workflows/draft_release.yaml b/.github/workflows/draft_release.yaml new file mode 100644 index 00000000..f6645005 --- /dev/null +++ b/.github/workflows/draft_release.yaml @@ -0,0 +1,71 @@ +name: Create Draft Release + +on: + push: + tags: + - "v*" + +jobs: + draft_release: + name: Create Draft Release + runs-on: ubuntu-latest + steps: + # - name: Set env + # run: echo "RELEASE_TAG=${GITHUB_REF:10}" >> $GITHUB_ENV + - name: Checkout the Repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Install Go + uses: actions/setup-go@v4 + with: + go-version: "^1.18" + # - name: generate release notes + # run: | + # make release-notes + - name: Create Licenses Report + run: | + make licenses-report + - name: Create Release + uses: softprops/action-gh-release@v1 + with: + draft: true + files: out/*.* + # body_path: _releasenotes/${{ env.RELEASE_TAG }}.md + + release_image: + name: Build and Push Release Image + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v3 + + - name: Install Go + uses: actions/setup-go@v4 + with: + go-version: "^1.18" + + - name: Create Licenses Report + run: | + make licenses-report + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2.1.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract Metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4.4.0 + with: + images: ghcr.io/telekom/das-schiff-network-operator + + - name: Build and Push Docker Image + uses: docker/build-push-action@v4.0.0 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.gitignore b/.gitignore index 368a40aa..dc7b57d8 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ *.so *.dylib bin +out testbin/* # Test binary, build with `go test -c` diff --git a/Makefile b/Makefile index 90dc01e7..f937242a 100644 --- a/Makefile +++ b/Makefile @@ -81,6 +81,19 @@ docker-build: test ## Build docker image with the manager. docker-push: ## Push docker image with the manager. docker push ${IMG} +##@ Release + +RELEASE_DIR ?= out + +$(RELEASE_DIR): + mkdir -p $(RELEASE_DIR)/ + +licenses-report: go-licenses + rm -rf $(RELEASE_DIR)/licenses + $(GO_LICENSES) save --save_path $(RELEASE_DIR)/licenses ./... + $(GO_LICENSES) report --template hack/licenses.md.tpl ./... > $(RELEASE_DIR)/licenses/licenses.md + (cd out/licenses && tar -czf ../licenses.tar.gz *) + ##@ Deployment ifndef ignore-not-found @@ -119,6 +132,11 @@ ENVTEST = $(shell pwd)/bin/setup-envtest envtest: ## Download envtest-setup locally if necessary. $(call go-get-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest@latest) +GO_LICENSES = $(shell pwd)/bin/go-licenses +.PHONY: go-licenses +go-licenses: ## Download go-licenses locally if necessary. + $(call go-get-tool,$(GO_LICENSES),github.com/google/go-licenses@latest) + # go-get-tool will 'go get' any package $2 and install it to $1. PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST)))) define go-get-tool @@ -128,7 +146,7 @@ TMP_DIR=$$(mktemp -d) ;\ cd $$TMP_DIR ;\ go mod init tmp ;\ echo "Downloading $(2)" ;\ -GOBIN=$(PROJECT_DIR)/bin go get $(2) ;\ +GOBIN=$(PROJECT_DIR)/bin go install $(2) ;\ rm -rf $$TMP_DIR ;\ } endef diff --git a/hack/licenses.md.tpl b/hack/licenses.md.tpl new file mode 100644 index 00000000..b3f2ec27 --- /dev/null +++ b/hack/licenses.md.tpl @@ -0,0 +1,5 @@ +# Dependency Licenses + +{{ range . }} + - {{.Name}}@{{.Version}} ([{{.LicenseName}}]({{.LicenseURL}})) +{{- end }} \ No newline at end of file