Skip to content

Commit

Permalink
Merge pull request #5628 from antoooks/release-helper-script
Browse files Browse the repository at this point in the history
Release helper script
  • Loading branch information
k8s-ci-robot authored Jul 16, 2024
2 parents 7cbaf78 + b1a9bff commit 1a41303
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 1 deletion.
27 changes: 26 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,39 @@ cd kustomize
git push origin myfeature
```

### Pull Request Rules

We are using [Conventional Commits v1.0.0](https://www.conventionalcommits.org/en/v1.0.0/) as the main guideline of making PR. This guideline serves to help contributor and maintainer to classify their changes, thus providing better insight on type of release will be covered on each Kustomize release cycle.

1. Please add these keywords on your PR titles accordingly

| Keyword | Description | Example |
| ------------- | ------------- | ------------- |
| fix | Patching or fixing bugs or improvements introduction from previous release. This type of change will mark a `PATCH` release. | fix: fix null value when generating yaml |
| feat | New features. This change will mark a `MINOR` release. | feat: new transformer and generator for ACME API CRD. |
| chore | Minor improvement outside main code base | chore: add exclusion for transformer test. |
| ci | CI/CD related changes (e.g. github workflow, scripts, CI steps). | ci: remove blocking tests |
| docs | Changes related to documentation. | docs: add rules documentation for PR. |


2. Add `BREAKING CHANGE:` on your commit message as footer to signify breaking changes. This will help maintainers identify `MAJOR` releases.

Example:

```
feat: change YAML parser from `yaml/v1` to `yaml/v2`
BREAKING CHANGE: parse() function now works with 2 arguments.
```

### Create a Pull Request

1. Visit your fork at `https://github.com/<user>/kustomize`
2. Click the **Compare & Pull Request** button next to your `myfeature` branch.
3. Check out the pull request [process](https://github.com/kubernetes/community/blob/master/contributors/guide/pull-requests.md) for more details and advice.

If you ran `git push` in the previous step, GitHub will return a useful link to create a Pull Request.


### Build Kustomize
The [Kustomize Architecture] document describes the respository organization and the kustomize build process.
```bash
Expand Down
50 changes: 50 additions & 0 deletions releasing/check-release-helper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env bash
# Copyright 2024 The Kubernetes Authors.
# SPDX-License-Identifier: Apache-2.0


declare PATCH=false
declare MINOR=false
declare MAJOR=false
declare rc=0

ORIGIN_MASTER="origin/master"
LATEST_TAG=$(git describe --tags --abbrev=0)

git log "${LATEST_TAG}..HEAD" --oneline | tee /tmp/release-changelogs.txt

count=$(cat /tmp/release-changelogs.txt | wc -l)

if [[ $(cat /tmp/release-changelogs.txt | grep fix) || $(cat /tmp/release-changelogs.txt | grep patch) || $(cat /tmp/release-changelogs.txt | grep chore) || $(cat /tmp/release-changelogs.txt | grep docs) ]]; then
PATCH=true
fi

if [[ $(cat /tmp/release-changelogs.txt | grep feat) ]]; then
MINOR=true
fi

for commit in $(cut -d' ' -f1 /tmp/release-changelogs.txt); do
git log --format=%B -n 1 $commit | grep "BREAKING CHANGE"
if [ $? -eq 0 ]; then
MAJOR=true
fi
done

for f in $(find api); do
git diff "${LATEST_TAG}...${ORIGIN_MASTER}" --exit-code -- "${f}"
if [ $? -eq 1 ]; then
echo "Found changes on api dir at ${f}"
MAJOR=true
fi
done

echo -e "\n"
echo -e "================================================================================="
echo "Change counter: $(echo $count | tr -s ' ')"
if [[ $MAJOR == false && $MINOR == false ]]; then
echo "Recommended release type: patch"
elif [[ $MAJOR == false && $MINOR == true ]]; then
echo "Recommended release type: minor"
else
echo "Recommended release type: major"
fi

0 comments on commit 1a41303

Please sign in to comment.