diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000000..5ded0c65ed --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,44 @@ +name: release + +on: + push: + # Sequence of patterns matched against refs/tags + tags: + - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 + +permissions: + contents: write # Allow to create a release. + +jobs: + build: + name: create draft release + runs-on: ubuntu-latest + steps: + - name: Set env + run: echo "RELEASE_TAG=${GITHUB_REF:10}" >> $GITHUB_ENV + - name: checkout code + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2 + with: + fetch-depth: 0 + - name: Calculate go version + run: echo "go_version=$(make go-version)" >> $GITHUB_ENV + - name: Set up Go + uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # tag=v5.1.0 + with: + go-version: ${{ env.go_version }} + - name: generate release artifacts + run: | + make release + - name: generate release notes + # Ignore failures for release-notes generation so they could still get + # generated manually before publishing. + run: | + make generate-release-notes || echo "Failed to generate release notes" >> _releasenotes/${{ env.RELEASE_TAG }}.md + env: + GH_TOKEN: ${{ github.token }} + - name: Release + uses: softprops/action-gh-release@01570a1f39cb168c169c802c3bceb9e93fb10974 # tag=v2.1.0 + with: + draft: true + files: out/* + body_path: _releasenotes/${{ env.RELEASE_TAG }}.md diff --git a/.gitignore b/.gitignore index dcedf6b2f3..fc57c85d5e 100644 --- a/.gitignore +++ b/.gitignore @@ -74,6 +74,9 @@ cscope.* *.test /hack/.test-cmd-auth +# Generated release notes +_releasenotes + # JUnit test output from ginkgo e2e tests /junit*.xml diff --git a/Makefile b/Makefile index a584cefccb..197aea982f 100644 --- a/Makefile +++ b/Makefile @@ -23,6 +23,9 @@ include $(ROOT_DIR_RELATIVE)/common.mk export GO111MODULE=on unexport GOPATH +# Go +GO_VERSION ?= 1.22.7 + # Directories. ARTIFACTS ?= $(REPO_ROOT)/_artifacts TOOLS_DIR := hack/tools @@ -378,8 +381,25 @@ staging-manifests: ##@ Release ## -------------------------------------- +ifneq (,$(findstring -,$(RELEASE_TAG))) + PRE_RELEASE=true +endif +PREVIOUS_TAG ?= $(shell git tag -l | grep -E "^v[0-9]+\.[0-9]+\.[0-9]+$$" | sort -V | grep -B1 $(RELEASE_TAG) | head -n 1 2>/dev/null) +## set by Prow, ref name of the base branch, e.g., main +RELEASE_DIR := out +RELEASE_NOTES_DIR := _releasenotes + +.PHONY: $(RELEASE_DIR) $(RELEASE_DIR): - mkdir -p $@ + mkdir -p $(RELEASE_DIR)/ + +.PHONY: $(RELEASE_NOTES_DIR) +$(RELEASE_NOTES_DIR): + mkdir -p $(RELEASE_NOTES_DIR)/ + +.PHONY: $(BUILD_DIR) +$(BUILD_DIR): + @mkdir -p $(BUILD_DIR) .PHONY: list-staging-releases list-staging-releases: ## List staging images for image promotion @@ -454,9 +474,14 @@ upload-gh-artifacts: $(GH) ## Upload artifacts to Github release release-alias-tag: # Adds the tag to the last build tag. gcloud container images add-tag -q $(CONTROLLER_IMG):$(TAG) $(CONTROLLER_IMG):$(RELEASE_ALIAS_TAG) -.PHONY: release-notes -release-notes: $(RELEASE_NOTES) ## Generate release notes - $(RELEASE_NOTES) $(RELEASE_NOTES_ARGS) +.PHONY: generate-release-notes ## Generate release notes +generate-release-notes: $(RELEASE_NOTES_DIR) $(RELEASE_NOTES) + # Reset the file + echo -n > $(RELEASE_NOTES_DIR)/$(RELEASE_TAG).md + if [ -n "${PRE_RELEASE}" ]; then \ + echo -e ":rotating_light: This is a RELEASE CANDIDATE. Use it only for testing purposes. If you find any bugs, file an [issue](https://github.com/kubernetes-sigs/cluster-api-provider-openstack/issues/new/choose).\n" >> $(RELEASE_NOTES_DIR)/$(RELEASE_TAG).md; \ + fi + "$(RELEASE_NOTES)" --from=$(PREVIOUS_TAG) >> $(RELEASE_NOTES_DIR)/$(RELEASE_TAG).md .PHONY: templates templates: ## Generate cluster templates @@ -570,3 +595,12 @@ compile-e2e: ## Test e2e compilation .PHONY: FORCE FORCE: + +## -------------------------------------- +## Helpers +## -------------------------------------- + +##@ helpers: + +go-version: ## Print the go version we use to compile our binaries and images + @echo $(GO_VERSION) diff --git a/RELEASE.md b/RELEASE.md index a86fd79693..df00a8103b 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -70,10 +70,7 @@ The content of the release notes differs depending on the type of release, speci for review and the promotion of the image. 1. Run `make release` to build artifacts to be attached to the GitHub release. 1. Generate and finalize the release notes and save them for the next step. - - Run `make release-notes RELEASE_NOTES_ARGS="--from "`. - - Depending on the type of release, substitute `` with the following: - - Stable releases: tag of the last stable release - - Pre-releases*: tag of the latest pre-release (or last stable release if there isn't one) + - Run `make release-notes`. - Pay close attention to the `## :question: Sort these by hand` section, as it contains items that need to be manually sorted. 1. Create a draft release in GitHub based on the tag created above - Name the release `Release [VERSION]` where VERSION is the full version string.