Skip to content

Commit acd0171

Browse files
committed
Automate GH release
1 parent 571f447 commit acd0171

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

.github/workflows/release.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
on:
2+
push:
3+
# Sequence of patterns matched against refs/tags
4+
tags:
5+
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
6+
7+
name: release
8+
9+
jobs:
10+
build:
11+
name: create draft release
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Set env
15+
run: echo "RELEASE_TAG=${GITHUB_REF:10}" >> $GITHUB_ENV
16+
- name: checkout code
17+
uses: actions/checkout@v2
18+
with:
19+
fetch-depth: 0
20+
- name: Install go
21+
uses: actions/setup-go@v2
22+
with:
23+
go-version: '^1.17'
24+
- name: generate release artifacts
25+
run: |
26+
make release
27+
- name: generate release notes
28+
run: |
29+
make release-notes
30+
- name: Release
31+
uses: softprops/action-gh-release@v1
32+
with:
33+
draft: true
34+
files: out/*
35+
body_path: _releasenotes/${{ env.RELEASE_TAG }}.md

Makefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,13 @@ BUCKET ?= $(STAGING_BUCKET)
8181
PROD_REGISTRY := k8s.gcr.io/cluster-api-aws
8282
REGISTRY ?= $(STAGING_REGISTRY)
8383
RELEASE_TAG ?= $(shell git describe --abbrev=0 2>/dev/null)
84+
# the previous release tag, e.g., v0.6.9, excluding pre-release tags
85+
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)
8486
PULL_BASE_REF ?= $(RELEASE_TAG) # PULL_BASE_REF will be provided by Prow
8587
RELEASE_ALIAS_TAG ?= $(PULL_BASE_REF)
8688
RELEASE_DIR := out
89+
RELEASE_NOTES_DIR := _releasenotes
8790
RELEASE_POLICIES := $(RELEASE_DIR)/AWSIAMManagedPolicyControllers.json $(RELEASE_DIR)/AWSIAMManagedPolicyControllersWithEKS.json $(RELEASE_DIR)/AWSIAMManagedPolicyCloudProviderControlPlane.json $(RELEASE_DIR)/AWSIAMManagedPolicyCloudProviderNodes.json
88-
8991
# image name used to build the cmd/clusterawsadm
9092
TOOLCHAIN_IMAGE := toolchain
9193

@@ -388,6 +390,9 @@ staging-manifests:
388390
$(RELEASE_DIR):
389391
mkdir -p $@
390392

393+
$(RELEASE_NOTES_DIR):
394+
mkdir -p $@
395+
391396
.PHONY: list-staging-releases
392397
list-staging-releases: ## List staging images for image promotion
393398
@echo $(CORE_IMAGE_NAME):
@@ -438,6 +443,10 @@ release-manifests:
438443
# Add metadata to the release artifacts
439444
cp metadata.yaml $(RELEASE_DIR)/metadata.yaml
440445

446+
.PHONY: release-notes
447+
release-notes: $(RELEASE_NOTES_DIR) $(RELEASE_NOTES)
448+
go run ./hack/tools/release/notes.go --from=$(PREVIOUS_TAG) > $(RELEASE_NOTES_DIR)/$(RELEASE_TAG).md
449+
441450
.PHONY: release-changelog
442451
release-changelog: $(RELEASE_NOTES) check-release-tag check-previous-release-tag check-github-token $(RELEASE_DIR) ## Builds the changelog for a release
443452
$(RELEASE_NOTES) --debug --org $(GH_ORG_NAME) --repo $(GH_REPO_NAME) --start-sha $(shell git rev-list -n 1 ${PREVIOUS_VERSION}) --end-sha $(shell git rev-list -n 1 ${RELEASE_TAG}) --output $(RELEASE_DIR)/CHANGELOG.md --go-template go-template:$(REPO_ROOT)/hack/changelog.tpl --dependencies=false --branch=main

0 commit comments

Comments
 (0)