Skip to content

Commit 4ef1ea9

Browse files
author
shiftstack-merge-bot
committed
2 parents 23512b6 + efcbbe9 commit 4ef1ea9

File tree

5 files changed

+90
-10
lines changed

5 files changed

+90
-10
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
@@ -25,6 +25,9 @@ export GOTOOLCHAIN=go1.22.8
2525
export GO111MODULE=on
2626
unexport GOPATH
2727

28+
# Go
29+
GO_VERSION ?= 1.22.7
30+
2831
# Directories.
2932
ARTIFACTS ?= $(REPO_ROOT)/_artifacts
3033
TOOLS_DIR := hack/tools
@@ -359,8 +362,25 @@ staging-manifests:
359362
##@ Release
360363
## --------------------------------------
361364

365+
ifneq (,$(findstring -,$(RELEASE_TAG)))
366+
PRE_RELEASE=true
367+
endif
368+
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)
369+
## set by Prow, ref name of the base branch, e.g., main
370+
RELEASE_DIR := out
371+
RELEASE_NOTES_DIR := _releasenotes
372+
373+
.PHONY: $(RELEASE_DIR)
362374
$(RELEASE_DIR):
363-
mkdir -p $@
375+
mkdir -p $(RELEASE_DIR)/
376+
377+
.PHONY: $(RELEASE_NOTES_DIR)
378+
$(RELEASE_NOTES_DIR):
379+
mkdir -p $(RELEASE_NOTES_DIR)/
380+
381+
.PHONY: $(BUILD_DIR)
382+
$(BUILD_DIR):
383+
@mkdir -p $(BUILD_DIR)
364384

365385
.PHONY: list-staging-releases
366386
list-staging-releases: ## List staging images for image promotion
@@ -435,9 +455,14 @@ upload-gh-artifacts: $(GH) ## Upload artifacts to Github release
435455
release-alias-tag: # Adds the tag to the last build tag.
436456
gcloud container images add-tag -q $(CONTROLLER_IMG):$(TAG) $(CONTROLLER_IMG):$(RELEASE_ALIAS_TAG)
437457

438-
.PHONY: release-notes
439-
release-notes: $(RELEASE_NOTES) ## Generate release notes
440-
$(RELEASE_NOTES) $(RELEASE_NOTES_ARGS)
458+
.PHONY: generate-release-notes ## Generate release notes
459+
generate-release-notes: $(RELEASE_NOTES_DIR) $(RELEASE_NOTES)
460+
# Reset the file
461+
echo -n > $(RELEASE_NOTES_DIR)/$(RELEASE_TAG).md
462+
if [ -n "${PRE_RELEASE}" ]; then \
463+
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; \
464+
fi
465+
"$(RELEASE_NOTES)" --from=$(PREVIOUS_TAG) >> $(RELEASE_NOTES_DIR)/$(RELEASE_TAG).md
441466

442467
.PHONY: templates
443468
templates: ## Generate cluster templates
@@ -557,3 +582,12 @@ compile-e2e: ## Test e2e compilation
557582

558583
.PHONY: FORCE
559584
FORCE:
585+
586+
## --------------------------------------
587+
## Helpers
588+
## --------------------------------------
589+
590+
##@ helpers:
591+
592+
go-version: ## Print the go version we use to compile our binaries and images
593+
@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.

controllers/openstackcluster_controller.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,11 @@ func (r *OpenStackClusterReconciler) reconcileDelete(ctx context.Context, scope
152152
// A bastion may have been created if cluster initialisation previously reached populating the network status
153153
// We attempt to delete it even if no status was written, just in case
154154
if openStackCluster.Status.Network != nil {
155-
// Attempt to resolve bastion resources before delete. We don't need to worry about starting if the resources have changed on update.
155+
// Attempt to resolve bastion resources before delete.
156+
// Even if we fail, we need to continue with the deletion or risk getting stuck.
157+
// For example, if the image doesn't exist, we do not have a bastion.
156158
if _, err := resolveBastionResources(scope, clusterResourceName, openStackCluster); err != nil {
157-
return reconcile.Result{}, err
159+
scope.Logger().Info("Failed to resolve bastion, continuing.", "error", err)
158160
}
159161

160162
if err := deleteBastion(scope, cluster, openStackCluster); err != nil {

0 commit comments

Comments
 (0)