-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
308 additions
and
249 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: CI | ||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
- release/* | ||
jobs: | ||
ci: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Install Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: 1.22.x | ||
- name: Setup QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- name: Setup Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Lint | ||
uses: golangci/golangci-lint-action@v6 | ||
with: | ||
version: v1.61 | ||
- name: Verify | ||
run: | | ||
make verify | ||
- name: Test | ||
run: | | ||
make test | ||
- name: Build | ||
env: | ||
TAG: ${{ github.ref_name }} | ||
COMMIT: ${{ github.sha }} | ||
uses: goreleaser/goreleaser-action@v6 | ||
with: | ||
distribution: goreleaser | ||
version: "~> v2" | ||
args: build --clean --snapshot | ||
- name: Image Build | ||
run: | | ||
make image | ||
env: | ||
TAG: dev | ||
REPO: cnrancher |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
jobs: | ||
release: | ||
permissions: | ||
contents: write # required for creating GH release | ||
id-token: write # required for reading vault secrets | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Login to DockerHub | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ vars.PUBLIC_REGISTRY }} | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- name: Setup QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- name: Setup Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
ref: ${{ github.ref_name}} | ||
- name: Install Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: 1.22.x | ||
- name: Lint | ||
uses: golangci/golangci-lint-action@v6 | ||
with: | ||
version: v1.61 | ||
- name: Verify | ||
run: | | ||
make verify | ||
- name: Test | ||
run: | | ||
make test | ||
- name: Go Release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required for creating GH release | ||
TAG: ${{ github.ref_name }} | ||
COMMIT: ${{ github.sha }} | ||
uses: goreleaser/goreleaser-action@v6 | ||
with: | ||
distribution: goreleaser | ||
version: "~> v2" | ||
args: release --clean --verbose | ||
- name: Image Push | ||
run: | | ||
make image-push | ||
env: | ||
TAG: ${{ github.ref_name }} | ||
REPO: ${{ vars.PUBLIC_REGISTRY }}/${{ secrets.DOCKERHUB_USERNAME }} | ||
- name: Upload Charts | ||
env: | ||
TAG: ${{ github.ref_name }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required for updating GH release | ||
run: | | ||
make chart | ||
for f in $(find dist/artifacts/ -name '*.tgz'); do | ||
echo "Uploading $f to GitHub release $TAG" | ||
gh release upload $TAG $f | ||
done | ||
echo "Charts successfully uploaded to GitHub release $TAG" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ go.work | |
|
||
# Build files | ||
/bin/ | ||
/build/ | ||
/dist/ | ||
/cce-operator | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# This is an example .goreleaser.yml file with some sensible defaults. | ||
# Make sure to check the documentation at https://goreleaser.com | ||
|
||
# The lines below are called `modelines`. See `:help modeline` | ||
# Feel free to remove those if you don't want/need to use them. | ||
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json | ||
# vim: set ts=2 sw=2 tw=0 fo=cnqoj | ||
|
||
version: 2 | ||
|
||
before: | ||
hooks: | ||
- go mod tidy | ||
|
||
builds: | ||
- env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- linux | ||
goarch: | ||
- amd64 | ||
- arm64 | ||
ldflags: | ||
- -extldflags -static | ||
- -s -w | ||
- -X github.com/cnrancher/cce-operator/pkg/utils.GitCommit={{.Env.COMMIT}} | ||
- -X github.com/cnrancher/cce-operator/pkg/utils.Version={{.Env.TAG}} | ||
main: ./main.go | ||
id: cce-operator | ||
binary: cce-operator | ||
|
||
release: | ||
prerelease: auto | ||
|
||
archives: | ||
- format: tar.gz | ||
# this name template makes the OS and Arch compatible with the results of `uname`. | ||
name_template: >- | ||
{{ .ProjectName }}_ | ||
{{- title .Os }}_ | ||
{{- if eq .Arch "amd64" }}x86_64 | ||
{{- else if eq .Arch "386" }}i386 | ||
{{- else }}{{ .Arch }}{{ end }} | ||
{{- if .Arm }}v{{ .Arm }}{{ end }} | ||
changelog: | ||
sort: asc | ||
filters: | ||
exclude: | ||
- "^docs:" | ||
- "^test:" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,49 @@ | ||
SCRIPTS := build test ci validate | ||
.PHONY: $(SCRIPTS) clean generate help | ||
TAG?=$(shell git describe --abbrev=0 --tags 2>/dev/null || echo "v0.0.0" ) | ||
COMMIT?=$(shell git rev-parse HEAD) | ||
|
||
.dapper: | ||
@echo Downloading dapper | ||
@curl -sL https://releases.rancher.com/dapper/latest/dapper-`uname -s`-`uname -m` > .dapper.tmp | ||
@chmod +x .dapper.tmp | ||
@./.dapper.tmp -v | ||
@mv .dapper.tmp .dapper | ||
default: build | ||
|
||
$(SCRIPTS): .dapper | ||
@./.dapper $@ | ||
.PHONY: generate | ||
generate: | ||
@go generate | ||
|
||
.PHONY: build | ||
build: | ||
COMMIT=$(COMMIT) TAG=$(TAG) goreleaser build --snapshot --clean | ||
|
||
.PHONY: test | ||
test: | ||
CGO_ENABLED=0 go test -cover --count=1 ./... | ||
|
||
.PHONY: clean | ||
clean: | ||
@./scripts/clean.sh | ||
./scripts/clean.sh | ||
|
||
generate: | ||
@go generate ./main.go | ||
.PHONY: verify | ||
verify: | ||
./scripts/verify.sh | ||
|
||
.PHONY: chart | ||
chart: | ||
TAG=$(TAG) ./scripts/chart.sh | ||
|
||
.PHONY: image | ||
image: | ||
TAG=$(TAG) ./scripts/image.sh | ||
|
||
.PHONY: image-push | ||
image-push: | ||
TAG=$(TAG) BUILDX_OPTIONS="--push" ./scripts/image.sh | ||
|
||
.PHONY: help | ||
help: | ||
@echo "Usage:" | ||
@echo " make build - Build executable files in 'bin' folder" | ||
@echo " make test - Run unit test" | ||
@echo " make generate - Generate codes & CRDs" | ||
@echo " make build build binary files" | ||
@echo " make test run unit tests" | ||
@echo " make generate run code generator" | ||
@echo " make verify verify modules" | ||
@echo " make chart package helm charts" | ||
@echo " make image build container images" | ||
@echo " make image-push build container images and push" | ||
@echo " make clean clean up built files" | ||
@echo " make help show this message" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.