Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pre-release: Update version to 0.0.0 #2812

Closed
wants to merge 12 commits into from
16 changes: 16 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,22 @@ jobs:
- name: restore_gosum
run: echo "${{needs.gomod.outputs.gosum}}" > go.sum
- run: make golint

reno_lint:
runs-on: ubuntu-20.04
needs: gomod
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
with:
fetch-depth: 0
- name: reset_git_extension
run: git config --unset-all extensions.worktreeconfig
- name: reno_lint
run: make reno-lint
## Reno lint does not catch some errors which make reno report fail
- name: reno_report_check
run: make reno-report

test:
runs-on: ubuntu-20.04
needs: gomod
Expand Down
57 changes: 57 additions & 0 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Pre release

on:
workflow_dispatch:
inputs:
release_tag:
description: 'Image tag in the format x.x.x'
required: true
type: string

env:
RELEASE_TAG: ${{ inputs.release_tag }}
PRERELEASE_DOCS_BRANCH: 'dg8d45z'

jobs:
## TODO we can add a condition like github.actor.role == 'Maintainer' to limit trigger to maintainers only
create_pr:
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
steps:
- name: checkout_repo
uses: actions/checkout@v4
with:
fetch-tags: true
fetch-depth: 0 # necessary for CURRENT_TAG tracing
- name: fetch_tags
run: git fetch --tags origin
- name: bump_version
run: |
export CURRENT_TAG=$(git describe --abbrev=0 --tags)
echo ./build/bump_version.sh "${CURRENT_TAG}" "${RELEASE_TAG}"
./build/bump_version.sh "${CURRENT_TAG}" "${RELEASE_TAG}"
make reno-report VERSION="${RELEASE_TAG}"
- name: commit_changes
run: |
git config --global user.name 'Kasten Production'
git config --global user.email 'infra@kasten.io'
git checkout -B "kan-docs-${PRERELEASE_DOCS_BRANCH}-${RELEASE_TAG}"
git add -A
git commit -s -m "pre-release: Update version to ${RELEASE_TAG}"
- name: push_changes
run: git push origin "kan-docs-${PRERELEASE_DOCS_BRANCH}-${RELEASE_TAG}"
- name: create_pr_body
run: |
echo "Update version to ${RELEASE_TAG}" > PR_BODY_FILE
echo "Merges to check changelog for:" >> PR_BODY_FILE
export CURRENT_TAG=$(git describe --abbrev=0 --tags)
echo git log ${CURRENT_TAG}..kan-docs-${PRERELEASE_DOCS_BRANCH}-${RELEASE_TAG} --pretty="- %h: %s" | grep -v ': test' | grep -v ': doc' | grep -v ': build' | grep -v ': deps'
git log ${CURRENT_TAG}..kan-docs-${PRERELEASE_DOCS_BRANCH}-${RELEASE_TAG} --pretty="- %h: %s" | grep -v ': test' | grep -v ': doc' | grep -v ': build' | grep -v ': deps' >> PR_BODY_FILE
- name: create_pr
run: |
gh pr create --title "pre-release: Update version to ${RELEASE_TAG}" -F PR_BODY_FILE --head "kan-docs-${PRERELEASE_DOCS_BRANCH}-${RELEASE_TAG}" --base master --reviewer tdmanv,pavannd1,viveksinghggits,hairyhum --label kueue
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@
/dist
**/*.swp
/.idea
/releasenotes/config.yaml
CHANGELOG.rst
CHANGELOG_CURRENT.rst
1 change: 1 addition & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,5 +153,6 @@ changelog:
exclude:
- '^docs:'
- '^test:'
- '^pre-release:'
archives:
- allow_different_binary_count: true
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Release Notes

## 0.0.0

## Release Summary

<!-- releasenotes/notes/test-ed852f25b491aefc.yaml @ b'eaf69cba2c10bba63ac2f87f1715a9ac88c91e1f' -->
test release notes

## New Features

<!-- releasenotes/notes/baz-b497459cec12cacb.yaml @ b'eaf69cba2c10bba63ac2f87f1715a9ac88c91e1f' -->
* another feature

<!-- releasenotes/notes/foo-0c0842e36cb1c4d6.yaml @ b'eaf69cba2c10bba63ac2f87f1715a9ac88c91e1f' -->
* a feature

<!-- releasenotes/notes/test-ed852f25b491aefc.yaml @ b'eaf69cba2c10bba63ac2f87f1715a9ac88c91e1f' -->
* test release notes

<!-- releasenotes/notes/test-ed852f25b491aefc.yaml @ b'eaf69cba2c10bba63ac2f87f1715a9ac88c91e1f' -->
* test pre-release generation

## Bug Fixes

<!-- releasenotes/notes/bar-b6d8be8126d5a8bd.yaml @ b'eaf69cba2c10bba63ac2f87f1715a9ac88c91e1f' -->
* a fix

<!-- releasenotes/notes/test-ed852f25b491aefc.yaml @ b'eaf69cba2c10bba63ac2f87f1715a9ac88c91e1f' -->
* test fixes field
30 changes: 30 additions & 0 deletions CHANGELOG_CURRENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Release Notes

## 0.0.0

## Release Summary

<!-- releasenotes/notes/test-ed852f25b491aefc.yaml @ b'eaf69cba2c10bba63ac2f87f1715a9ac88c91e1f' -->
test release notes

## New Features

<!-- releasenotes/notes/baz-b497459cec12cacb.yaml @ b'eaf69cba2c10bba63ac2f87f1715a9ac88c91e1f' -->
* another feature

<!-- releasenotes/notes/foo-0c0842e36cb1c4d6.yaml @ b'eaf69cba2c10bba63ac2f87f1715a9ac88c91e1f' -->
* a feature

<!-- releasenotes/notes/test-ed852f25b491aefc.yaml @ b'eaf69cba2c10bba63ac2f87f1715a9ac88c91e1f' -->
* test release notes

<!-- releasenotes/notes/test-ed852f25b491aefc.yaml @ b'eaf69cba2c10bba63ac2f87f1715a9ac88c91e1f' -->
* test pre-release generation

## Bug Fixes

<!-- releasenotes/notes/bar-b6d8be8126d5a8bd.yaml @ b'eaf69cba2c10bba63ac2f87f1715a9ac88c91e1f' -->
* a fix

<!-- releasenotes/notes/test-ed852f25b491aefc.yaml @ b'eaf69cba2c10bba63ac2f87f1715a9ac88c91e1f' -->
* test fixes field
18 changes: 15 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ REGISTRY ?= kanisterio
ARCH ?= amd64

# This version-strategy uses git tags to set the version string
VERSION := $(shell git describe --tags --always --dirty)
VERSION ?= $(shell git describe --tags --always --dirty)
#
# This version-strategy uses a manual value to set the version string
#VERSION := 1.2.3
Expand Down Expand Up @@ -70,6 +70,10 @@ GOBORING ?= ""

CONTROLLER_TOOLS_VERSION ?= "v0.12.0"

## Changelog file for goreleaser

CHANGELOG_FILE ?= ./CHANGELOG_CURRENT.md

# If you want to build all binaries, see the 'all-build' rule.
# If you want to build all containers, see the 'all-container' rule.
# If you want to build AND push all containers, see the 'all-push' rule.
Expand Down Expand Up @@ -207,7 +211,7 @@ ifeq ($(DOCKER_BUILD),"true")
@echo "running CMD in the containerized build environment"
@PWD=$(PWD) ARCH=$(ARCH) PKG=$(PKG) GITHUB_TOKEN=$(GITHUB_TOKEN) CMD="$(CMD)" /bin/bash ./build/run_container.sh run
else
@/bin/bash $(CMD)
@/bin/bash -c "$(CMD)"
endif

clean: dotfile-clean bin-clean
Expand Down Expand Up @@ -236,7 +240,7 @@ release-helm:
@/bin/bash ./build/release_helm.sh $(VERSION)

gorelease:
@$(MAKE) run CMD="./build/gorelease.sh"
@$(MAKE) run CMD="CHANGELOG_FILE=$(CHANGELOG_FILE) ./build/gorelease.sh"

release-snapshot:
@$(MAKE) run CMD="GORELEASER_CURRENT_TAG=v9.99.9-dev goreleaser --debug release --rm-dist --snapshot --timeout=60m0s"
Expand Down Expand Up @@ -284,3 +288,11 @@ uninstall-crds: ## Uninstall CRDs from the K8s cluster specified in ~/.kube/conf
manifests: ## Generates CustomResourceDefinition objects.
@$(MAKE) run CMD="./build/generate_crds.sh ${CONTROLLER_TOOLS_VERSION}"

reno-new:
@$(MAKE) run CMD="reno new $(note)"

reno-report:
@$(MAKE) run CMD="./build/reno_report.sh $(VERSION)"

reno-lint:
@$(MAKE) run CMD="reno lint"
137 changes: 137 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
## Automated Release

Release process:

- Verify the release version by looking at the [releases page](https://github.com/kanisterio/kanister/releases) on the Kanister repo.
- Trigger the [pre-release](#pre-release-workflow) workflow with the desired version number (e.g. bump the minor version portion 0.106.0 -> 0.107.0)
- Review and validate created PR that it doesn't have any unintended changes
- Make sure to validate that all merged PRs in the release have [release notes](#release-notes)
- Make sure that CHANGELOG.md and CHANGELOG_CURRENT.md contain release notes for the release version
- **NOTE** While we establish the new process of release notes, it may be required to add notes in pre-release step by commiting them into pre-release branch
- Approve and merge the pre-release PR (it will be merged by `kueue` when approved)
- Merging of pre-release PR will trigger the `kanister/release` pipeline in codefresh
- The Kanister release job will publish a new tag, update documentation, build all the docker images, and push them to the [ghcr.io](https://github.com/orgs/kanisterio/packages) registry.
- After completing the Kanister part, the job will open a PR on K10 to update the Kanister version in K10 docs, tests, and the base image of the kanister-tools docker image. Example PR: https://github.com/kastenhq/k10/pull/23956
- Once the job is complete, a Slack notification will be sent to the kanister channel on the Kasten workspace.
- **NOTE** We need to update the GVS blueprint version in the kio/kanister/blueprint.go file to ensure that the new kanister-tools image will be used for Kopia operations. Push a commit to the PR opened above to do this. Example: https://github.com/kastenhq/k10/pull/23956/commits/83a62ccb17af52fd331012239dea97e02180817b
- Once the PR is approved, the Kanister release is complete.
- Additionally, we could also approve the K10 go.mod update to bring in the latest changes in K10. Example PR: https://github.com/kastenhq/k10/pull/24589

### Pre-release workflow

`pre-release` workflow serves to create a new version of kanister, it updates version number and creates a PR in kanister repo.

The workflow can be triggered using workflow dispatch from the `Actions` tab in the repo: https://github.com/kanisterio/kanister/actions/workflows/pre-release.yml
It has a required input of `release_tag`, which should be set to a version next to the current version.

This will result in creating a PR with a version bump, like https://github.com/kanisterio/kanister/pull/2629
**NOTE** PR description would look like `pre-release: Update version to ...`

This PR would contain an update of version in various files.


### Release notes

When working on pre-release PR the person doing the release should check that merged PRs have release notes when necessary.

It can be checked by running a diff with previous release and looking at the PR commits:

```
git log 0.106.0..HEAD --invert-grep --grep='deps' --grep='docs' --grep='build' | grep -oh '^.*\(#[0-9]*\)'
```

And verifying that PRs have release notes.

This is a bit tedious, but should be less of an issue as we establish a process of adding release notes.


## Handling Failures

### Retry

Depending on where the release failed, some of the following steps may have succeeded:

- Creation of a new tag in the kanister repo
- PR raised in kanister to update kanister tools
- PR raised in K10 to update kanister tools version

Before rerunning the release job manually, do the following:

- Delete the tag manually from GitHub
- Close the PRs created (to avoid confusion)

## Manual Release (Only needed when automation is broken)

Prerequisites:

- Make sure you have admin access or access to push tags on Kanister
- Make sure you have push access to the K10 repo
- Make sure you have access to [push images to GHCR](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry)

### Kanister Repo

1. Create a release tag

```
$ export RELEASE_TAG="0.43.0"
$ git checkout master
$ git pull origin master
$ git tag -a "${RELEASE_TAG}" -m "Release version";
$ git push origin "${RELEASE_TAG}"
```

2. Release binaries and docker images

```
$ make reno-report
$ make gorelease CHANGELOG_FILE=./CHANGELOG.md
```

3. Update and release docs and helms charts

```
$ export PREV_TAG="0.42.0"
$ git checkout -b "kan-docs-${RELEASE_TAG}"
$ ./build/bump_version.sh "${PREV_TAG}" "${RELEASE_TAG}"
$ git add -A
$ git commit -m"Kanister docs update to version ${RELEASE_TAG}"
$ git push origin kan-docs-${RELEASE_TAG}

```

Go ahead and raise PR against master through GitHub UI

### K10 Repo

4. Refresh artifacts

```
$ build.sh docker_run invalidate_cloudfront -e kanisterrelease

```

5. Bump kanister tools version in K10

```
$ export RELEASE_TAG="0.43.0"
$ export PREV_TAG="0.41.0"
$ git checkout -b "kantools-bump-${RELEASE_TAG}"
$ /path/to/kanister/build/bump_version.sh "${PREV_TAG}" "${RELEASE_TAG}" .
$ git add -A
$ git commit -m"Update kanister tools version to ${RELEASE_TAG}"
$ git push origin kantools-bump-${RELEASE_TAG}
```

Go ahead and raise PR against master through GitHub UI

### Publish Kanister Release

Finally, go to https://github.com/kanisterio/kanister/releases, and publish the draft release

## Post-release Checks

- Verify the Kanister [repo](https://github.com/kanisterio/kanister/releases) for the new release tag.

- Verify if the docker [images](https://github.com/orgs/kanisterio/packages?repo_name=kanister) have a new tag. NOTE: Not all docker images are relevant.
TODO: Add a list of the most relevant docker images to be verified here.

12 changes: 11 additions & 1 deletion build/gorelease.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,14 @@ then
echo "You can generate a token here: https://github.com/settings/tokens/new"
exit 1
fi
goreleaser release --parallelism=1 --rm-dist --debug --timeout 120m

## Set default changelog file
CHANGELOG_FILE=${CHANGELOG_FILE:-./CHANGELOG_CURRENT.md}

RELEASE_NOTES=""
if [ -n "${CHANGELOG_FILE:-}" ]
then
RELEASE_NOTES="--release-notes ${CHANGELOG_FILE}"
fi

goreleaser release --parallelism=1 --rm-dist --debug --timeout 120m ${RELEASE_NOTES}
Loading
Loading