Skip to content

Commit 7e898a9

Browse files
authored
Merge pull request #2289 from kubernetes-sigs/release
🌱 Automate the release process
2 parents 1855926 + 85334e3 commit 7e898a9

File tree

4 files changed

+86
-8
lines changed

4 files changed

+86
-8
lines changed

.github/workflows/release.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: release
2+
3+
on:
4+
push:
5+
# Sequence of patterns matched against refs/tags
6+
tags:
7+
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
8+
9+
permissions:
10+
contents: write # Allow to create a release.
11+
12+
jobs:
13+
build:
14+
name: create draft release
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Set env
18+
run: echo "RELEASE_TAG=${GITHUB_REF:10}" >> $GITHUB_ENV
19+
- name: checkout code
20+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
21+
with:
22+
fetch-depth: 0
23+
- name: Calculate go version
24+
run: echo "go_version=$(make go-version)" >> $GITHUB_ENV
25+
- name: Set up Go
26+
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # tag=v5.1.0
27+
with:
28+
go-version: ${{ env.go_version }}
29+
- name: generate release artifacts
30+
run: |
31+
make release
32+
- name: generate release notes
33+
# Ignore failures for release-notes generation so they could still get
34+
# generated manually before publishing.
35+
run: |
36+
make generate-release-notes || echo "Failed to generate release notes" >> _releasenotes/${{ env.RELEASE_TAG }}.md
37+
env:
38+
GH_TOKEN: ${{ github.token }}
39+
- name: Release
40+
uses: softprops/action-gh-release@01570a1f39cb168c169c802c3bceb9e93fb10974 # tag=v2.1.0
41+
with:
42+
draft: true
43+
files: out/*
44+
body_path: _releasenotes/${{ env.RELEASE_TAG }}.md

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ cscope.*
7474
*.test
7575
/hack/.test-cmd-auth
7676

77+
# Generated release notes
78+
_releasenotes
79+
7780
# JUnit test output from ginkgo e2e tests
7881
/junit*.xml
7982

Makefile

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ include $(ROOT_DIR_RELATIVE)/common.mk
2323
export GO111MODULE=on
2424
unexport GOPATH
2525

26+
# Go
27+
GO_VERSION ?= 1.22.7
28+
2629
# Directories.
2730
ARTIFACTS ?= $(REPO_ROOT)/_artifacts
2831
TOOLS_DIR := hack/tools
@@ -378,8 +381,25 @@ staging-manifests:
378381
##@ Release
379382
## --------------------------------------
380383

384+
ifneq (,$(findstring -,$(RELEASE_TAG)))
385+
PRE_RELEASE=true
386+
endif
387+
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)
388+
## set by Prow, ref name of the base branch, e.g., main
389+
RELEASE_DIR := out
390+
RELEASE_NOTES_DIR := _releasenotes
391+
392+
.PHONY: $(RELEASE_DIR)
381393
$(RELEASE_DIR):
382-
mkdir -p $@
394+
mkdir -p $(RELEASE_DIR)/
395+
396+
.PHONY: $(RELEASE_NOTES_DIR)
397+
$(RELEASE_NOTES_DIR):
398+
mkdir -p $(RELEASE_NOTES_DIR)/
399+
400+
.PHONY: $(BUILD_DIR)
401+
$(BUILD_DIR):
402+
@mkdir -p $(BUILD_DIR)
383403

384404
.PHONY: list-staging-releases
385405
list-staging-releases: ## List staging images for image promotion
@@ -454,9 +474,14 @@ upload-gh-artifacts: $(GH) ## Upload artifacts to Github release
454474
release-alias-tag: # Adds the tag to the last build tag.
455475
gcloud container images add-tag -q $(CONTROLLER_IMG):$(TAG) $(CONTROLLER_IMG):$(RELEASE_ALIAS_TAG)
456476

457-
.PHONY: release-notes
458-
release-notes: $(RELEASE_NOTES) ## Generate release notes
459-
$(RELEASE_NOTES) $(RELEASE_NOTES_ARGS)
477+
.PHONY: generate-release-notes ## Generate release notes
478+
generate-release-notes: $(RELEASE_NOTES_DIR) $(RELEASE_NOTES)
479+
# Reset the file
480+
echo -n > $(RELEASE_NOTES_DIR)/$(RELEASE_TAG).md
481+
if [ -n "${PRE_RELEASE}" ]; then \
482+
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; \
483+
fi
484+
"$(RELEASE_NOTES)" --from=$(PREVIOUS_TAG) >> $(RELEASE_NOTES_DIR)/$(RELEASE_TAG).md
460485

461486
.PHONY: templates
462487
templates: ## Generate cluster templates
@@ -570,3 +595,12 @@ compile-e2e: ## Test e2e compilation
570595

571596
.PHONY: FORCE
572597
FORCE:
598+
599+
## --------------------------------------
600+
## Helpers
601+
## --------------------------------------
602+
603+
##@ helpers:
604+
605+
go-version: ## Print the go version we use to compile our binaries and images
606+
@echo $(GO_VERSION)

RELEASE.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,7 @@ The content of the release notes differs depending on the type of release, speci
7070
for review and the promotion of the image.
7171
1. Run `make release` to build artifacts to be attached to the GitHub release.
7272
1. Generate and finalize the release notes and save them for the next step.
73-
- Run `make release-notes RELEASE_NOTES_ARGS="--from <tag>"`.
74-
- Depending on the type of release, substitute `<tag>` with the following:
75-
- Stable releases: tag of the last stable release
76-
- Pre-releases*: tag of the latest pre-release (or last stable release if there isn't one)
73+
- Run `make release-notes`.
7774
- Pay close attention to the `## :question: Sort these by hand` section, as it contains items that need to be manually sorted.
7875
1. Create a draft release in GitHub based on the tag created above
7976
- Name the release `Release [VERSION]` where VERSION is the full version string.

0 commit comments

Comments
 (0)