Skip to content

Commit

Permalink
Simplifiy release note generation
Browse files Browse the repository at this point in the history
  • Loading branch information
caseydavenport committed Apr 17, 2018
1 parent 1e4b4c2 commit b942fa8
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 41 deletions.
65 changes: 35 additions & 30 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,10 @@ ut: vendor

.PHONY: fv
## Build and run the FV tests.
GINKGO_FOCUS?=.*
fv: tests/fv/fv.test image
@echo Running Go FVs.
cd tests/fv && ETCD_IMAGE=$(ETCD_IMAGE) HYPERKUBE_IMAGE=$(HYPERKUBE_IMAGE) CONTAINER_NAME=$(CONTAINER_NAME) ./fv.test -ginkgo.slowSpecThreshold 30
cd tests/fv && ETCD_IMAGE=$(ETCD_IMAGE) HYPERKUBE_IMAGE=$(HYPERKUBE_IMAGE) CONTAINER_NAME=$(CONTAINER_NAME) ./fv.test -ginkgo.slowSpecThreshold 30 -ginkgo.focus $(GINKGO_FOCUS)

GET_CONTAINER_IP := docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}'
K8S_VERSION=1.7.5
Expand Down Expand Up @@ -168,13 +169,27 @@ check-copyright:
###############################################################################
# Release targets
###############################################################################
PREVIOUS_RELEASE=$(shell git describe --tags --abbrev=0)

## Tags and builds a release from start to finish.
release: release-prereqs
$(MAKE) VERSION=$(VERSION) release-tag
$(MAKE) VERSION=$(VERSION) release-build
$(MAKE) VERSION=$(VERSION) release-verify

@echo ""
@echo "Release build complete. Next, push the produced images."
@echo ""
@echo " make VERSION=$(VERSION) release-publish"
@echo ""

## Produces a git tag for the release.
release-tag: release-prereqs
git tag $(VERSION)
release-tag: release-prereqs release-notes
git tag $(VERSION) -F release-notes-$(VERSION)
@echo ""
@echo "Now you can build the release:"
@echo ""
@echo " make release-build VERSION=$(VERSION)"
@echo " make VERSION=$(VERSION) release-build"
@echo ""

## Produces a clean build of release artifacts at the specified version.
Expand All @@ -191,22 +206,20 @@ endif
# Generate the `latest` images.
docker tag $(CONTAINER_NAME) quay.io/$(CONTAINER_NAME):latest

@echo "Now verify the release and push the git tag and artifacts:"
@echo ""
@echo " make release-verify release-publish VERSION=$(VERSION)"
@echo ""
@echo "If this is the latest stable release, also push latest images:"
@echo ""
@echo " make release-publish-latest VERSION=$(VERSION)"

## Verifies the release artifacts produces by `make release-build` are correct.
release-verify: release-prereqs
# Check the reported version is correct for each release artifact.
if ! docker run calico/kube-controllers:$(VERSION) -v | grep '^$(VERSION)$$'; then echo "Reported version:" `docker run calico/kube-controllers:$(VERSION) -v` "\nExpected version: $(VERSION)"; false; else echo "\nVersion check passed\n"; fi
if ! docker run quay.io/calico/kube-controllers:$(VERSION) -v | grep '^$(VERSION)$$'; then echo "Reported version:" `docker run quay.io/calico/kube-controllers:$(VERSION) -v` "\nExpected version: $(VERSION)"; false; else echo "\nVersion check passed\n"; fi

# Run FV tests against the produced image.
$(MAKE) CONTAINER_NAME=calico/kube-controllers:$(VERSION) st
# Run FV tests against the produced image. We only run the subset tagged as release tests.
$(MAKE) CONTAINER_NAME=calico/kube-controllers:$(VERSION) GINKGO_FOCUS="Release" fv

## Generates release notes based on commits in this version.
release-notes: release-prereqs
mkdir -p dist
echo "# Changelog" > release-notes-$(VERSION)
sh -c "git cherry -v $(PREVIOUS_RELEASE) | cut '-d ' -f 2- | sed 's/^/- /' >> release-notes-$(VERSION)"

## Pushes a github release and release artifacts produced by `make release-build`.
release-publish: release-prereqs
Expand All @@ -217,22 +230,14 @@ release-publish: release-prereqs
docker push calico/kube-controllers:$(VERSION)
docker push quay.io/calico/kube-controllers:$(VERSION)

# Make a draft of the release notes.
$(MAKE) release-notes

@echo "Complete the release process on GitHub"

# Run gren in a container in order to generate a GitHub release with the correct
# release notes. See here for more info: https://github.com/github-tools/github-release-notes
release-notes: release-prereqs
ifndef GITHUB_TOKEN
$(error GITHUB_TOKEN is undefined - run using make release-notes GITHUB_TOKEN=X)
endif
docker run -ti --rm \
-v $(PWD):/code \
-e GREN_GITHUB_TOKEN=$(GITHUB_TOKEN) \
-e VERSION=$(VERSION) \
node bash -c "npm install github-release-notes -g && cd /code && gren release -d -t $(VERSION)"
@echo "Finalize the GitHub release based on the pushed tag."
@echo ""
@echo " https://github.com/projectcalico/kube-controllers/releases/tag/$(VERSION)"
@echo ""
@echo "If this is the latest stable release, then run the following to push 'latest' images."
@echo ""
@echo " make VERSION=$(VERSION) release-publish-latest"
@echo ""

# WARNING: Only run this target if this release is the latest stable release. Do NOT
# run this target for alpha / beta / release candidate builds, or patches to earlier Calico versions.
Expand Down
69 changes: 62 additions & 7 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,72 @@

## Resulting artifacts
Creating a new release creates the following artifact

* `calico/kube-controllers:$VERSION` container images (and the quay.io variant)

## Preparing for a release
Ensure that the branch you want to release from (typically master) is in a good state.
e.g. Update any pins in glide.yaml, create PR, ensure tests pass and merge.

Checkout the branch from which you want to release. For a major or minor release,
you will need to create a new `release-vX.Y` branch based on the target Calico version.

Make sure the branch is in a good state, e.g. Update any pins in glide.yaml, create PR, ensure tests pass and merge.

You should have no local changes and tests should be passing.

## Creating the release
1. Choose a version e.g. `v1.0.0`
2. Create the release artifacts repositories `make release VERSION=v1.0.0`.
3. Follow the instructions from `make release` to push the artifacts and git tag.
4. Create a release on Github, using the tag which was just pushed.
## Creating a patch release

1. Choose a version e.g. `v1.0.1`

1. Create the release. This will generate release notes, a tag, build the code, and verify the artifacts.

```
make VERSION=v1.0.1 release
```

1. Publish the release.

```
make VERSION=v1.0.1 release-publish
```

1. Publish the release on GitHub by following the link printed to screen.
- Copy the tag description, press edit, and paste it into the release body.
- Remove or clean up any messy commits - e.g. libcalico-go updates.
- Title the release the same as the tag - e.g. `v1.0.1`
- Press "Publish release"

1. If this is the latest stable release, perform the following step to publish the `latest` images. **Do not perform
this step for patches to older releases.**

```
make VERSION=<version> release-publish-latest
```

## Creating a major / minor release

1. Choose a version e.g. `v1.1.0`

1. Create the release. This will generate release notes, a tag, build the code, and verify the artifacts.

```
make VERSION=v1.1.0 PREVIOUS_RELEASE=v1.0.0 release
```

1. Publish the release.

```
make VERSION=v1.1.0 release-publish
```

1. Publish the release on GitHub by following the link printed to screen.
- Copy the tag description, press edit, and paste it into the release body.
- Remove or clean up any messy commits - e.g. libcalico-go updates.
- Title the release the same as the tag - e.g. `v1.1.0`
- Press "Publish release"

1. If this is the latest stable release, perform the following step to publish the `latest` images. **Do not perform
this step for patches to older releases.**

```
make VERSION=<version> release-publish-latest
```
8 changes: 4 additions & 4 deletions tests/fv/fv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ var _ = Describe("kube-controllers FV tests", func() {
Expect(*info.Spec.DatastoreReady).To(BeTrue())
})

Context("nodes", func() {
It("should be removed in response to a k8s node delete", func() {
Context("Node FV tests", func() {
It("should be removed in response to a k8s node delete [Release]", func() {
kn := &v1.Node{
ObjectMeta: metav1.ObjectMeta{
Name: kNodeName,
Expand Down Expand Up @@ -382,7 +382,7 @@ var _ = Describe("kube-controllers FV tests", func() {
}, time.Second*15, 500*time.Millisecond).ShouldNot(HaveOccurred())
})

It("should update existing profiles in etcd to match namespaces in k8s", func() {
It("should update existing profiles in etcd to match namespaces in k8s [Release]", func() {
profile, err := calicoClient.Profiles().Get(context.Background(), profName, options.GetOptions{})
By("getting the profile", func() {
Expect(err).ShouldNot(HaveOccurred())
Expand Down Expand Up @@ -469,7 +469,7 @@ var _ = Describe("kube-controllers FV tests", func() {
}, time.Second*15, 500*time.Millisecond).ShouldNot(HaveOccurred())
})

It("should re-program policies that have changed in etcd", func() {
It("should re-program policies that have changed in etcd [Release]", func() {
p, err := calicoClient.NetworkPolicies().Get(context.Background(), policyNamespace, genPolicyName, options.GetOptions{})
By("getting the policy", func() {
Expect(err).ShouldNot(HaveOccurred())
Expand Down

0 comments on commit b942fa8

Please sign in to comment.