diff --git a/.github/workflows/draft-release.yaml b/.github/workflows/draft-release.yaml new file mode 100644 index 000000000..2c3bc90d6 --- /dev/null +++ b/.github/workflows/draft-release.yaml @@ -0,0 +1,37 @@ +name: Draft Release + +on: + push: + # Build and publish artifacts when new tag is created for release + tags: + - "v*.*.*" + +jobs: + build: + runs-on: ubuntu-latest + steps: + + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.16 + + - name: Build Release Artifacts + run: IMG="projects.registry.vmware.com/cluster_api_provider_bringyourownhost/cluster-api-byoh-controller:${{ env.GITHUB_REF }}" make build-release-artifacts + + - name: Publish Release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + draft: true + generate_release_notes: true + files: | + _dist/byoh-hostagent-linux-amd64 + _dist/cluster-template.yaml + _dist/infrastructure-components.yaml + _dist/metadata.yaml + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 26bf99980..4e3c8b291 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,9 @@ bin # Output of the go coverage tool, specifically when used with LiteIDE *.out +# Distribution related files +_dist + # Kubernetes Generated files - skip generated files, except for vendored files !vendor/**/zz_generated.* diff --git a/Makefile b/Makefile index 6e8c71204..ee99b25b7 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,7 @@ STAGING_REGISTRY ?= gcr.io/k8s-staging-cluster-api IMAGE_NAME ?= cluster-api-byoh-controller TAG ?= dev +RELEASE_DIR := _dist # Image URL to use all building/pushing image targets IMG ?= ${STAGING_REGISTRY}/${IMAGE_NAME}:${TAG} @@ -168,6 +169,29 @@ host-agent-binary: $(RELEASE_DIR) -o ./bin/$(notdir $(RELEASE_BINARY))-$(GOOS)-$(GOARCH) $(HOST_AGENT_DIR) +##@Release + +$(RELEASE_DIR): + rm -rf $(RELEASE_DIR) + mkdir -p $(RELEASE_DIR) + +build-release-artifacts: build-cluster-templates build-infra-yaml build-metadata-yaml build-host-agent-binary + +build-cluster-templates: $(RELEASE_DIR) cluster-templates + cp $(BYOH_TEMPLATES)/v1beta1/cluster-template.yaml $(RELEASE_DIR)/cluster-template.yaml + sed -i -e 1,20d $(RELEASE_DIR)/cluster-template.yaml + +build-infra-yaml:kustomize # Generate infrastructure-components.yaml for the provider + cd config/manager && $(KUSTOMIZE) edit set image gcr.io/k8s-staging-cluster-api/cluster-api-byoh-controller=${IMG} + $(KUSTOMIZE) build config/default > $(RELEASE_DIR)/infrastructure-components.yaml + +build-metadata-yaml: + cp metadata.yaml $(RELEASE_DIR)/metadata.yaml + +build-host-agent-binary: host-agent-binaries + cp bin/byoh-hostagent-linux-amd64 $(RELEASE_DIR)/byoh-hostagent-linux-amd64 + + # 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