Skip to content

Commit

Permalink
Update release related files (#444)
Browse files Browse the repository at this point in the history
  • Loading branch information
arybolovlev authored Jul 25, 2024
1 parent 5ccb487 commit 5207543
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .changie.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ versionExt: md
versionFormat: '## {{.Version}} ({{.Time.Format "January 02, 2006"}})'
fragmentFileFormat: '{{.Kind}}-{{.Custom.PR}}-{{.Time.Format "20060102-150405"}}'
kindFormat: '{{.Kind}}:'
changeFormat: '* {{.Body}} [[GH-{{.Custom.PR}}](https://github.com/hashicorp/terraform-cloud-operator/pull/{{.Custom.PR}})]'
changeFormat: '* {{.Body}} [[GH-{{.Custom.PR}}](https://github.com/hashicorp/hcp-terraform-operator/pull/{{.Custom.PR}})]'
custom:
- key: PR
label: PR Number
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ We value your desire to contribute by introducing new features or enhancing exis
1. Clone this repo

```console
$ git clone https://github.com/hashicorp/terraform-cloud-operator.git
$ cd terraform-cloud-operator
$ git clone https://github.com/hashicorp/hcp-terraform-operator.git
$ cd hcp-terraform-operator
```

1. Prepare a Kubernetes cluster
Expand Down
18 changes: 11 additions & 7 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ To create a new release, adhere to the following steps:
- Generate the version number that will be released. Throughout the following steps, it will be denoted as `<SEMVER>`.

```console
$ export TFC_OPERATOR_RELEASE_VERSION=`changie next auto`
$ export HCP_TF_OPERATOR_RELEASE_VERSION=`changie next auto`
```

- Create a new branch from the `main`. The branch name is required to adhere to the following template: `release/v<SEMVER>`.

```console
$ git checkout -b release/v$TFC_OPERATOR_RELEASE_VERSION
$ git checkout -b release/v$HCP_TF_OPERATOR_RELEASE_VERSION
```

- Modify the `version/VERSION` file to reflect the version number that you plan to release.

```console
$ echo $TFC_OPERATOR_RELEASE_VERSION > version/VERSION
$ echo $HCP_TF_OPERATOR_RELEASE_VERSION > version/VERSION
```

- Update the [`CHANGELOG`](./CHANGELOG.md) file with the change that were made since the last release.
Expand All @@ -40,25 +40,29 @@ To create a new release, adhere to the following steps:
$ changie merge
```

- Execute the script [update-helm-chart.sh](./scripts/update-helm-chart.sh) to update the [`Chart.yaml`](./charts/terraform-cloud-operator/Chart.yaml) file and match the desired release number. _The values of `version` and `appVersion` will be updated accordingly to the <SEMVER> value._
- Execute the script [update-helm-chart.sh](./scripts/update-helm-chart.sh) to update the [`Chart.yaml`](./charts/hcp-terraform-operator/Chart.yaml) file and match the desired release number. _The values of `version` and `appVersion` will be updated accordingly to the <SEMVER> value._


```console
$ scripts/update-helm-chart.sh
```

- Run `make helm-docs` to update the Helm Chart [`README.md`](./charts/terraform-cloud-operator/README.md) file.
- Update the Helm Chart [`README.md`](./charts/hcp-terraform-operator/README.md) file.

```console
$ make helm-docs
```

- Commit and push all changes that were made.

```console
$ git add -A
$ git commit -m "v$TFC_OPERATOR_RELEASE_VERSION"
$ git commit -m "v$HCP_TF_OPERATOR_RELEASE_VERSION"
$ git push
```

- Create a pull request against the `main` branch and follow the standard code review and merge procedures.

- After merging the release branch into the `main` branch, a git tag should have been automatically created for the new release version number. The version number in the tag must correspond with the `<SEMVER>` of the merged release branch name. Confirm this success by viewing the repository [tags](https://github.com/hashicorp/terraform-cloud-operator/tags).
- After merging the release branch into the `main` branch, a git tag should have been automatically created for the new release version number. The version number in the tag must correspond with the `<SEMVER>` of the merged release branch name. Confirm this success by viewing the repository [tags](https://github.com/hashicorp/hcp-terraform-operator/tags).

- Follow the [CRT Usage](https://hashicorp.atlassian.net/wiki/spaces/RELENG/pages/2309390389/Part+3+CRT+Usage) guide to promote the release to the staging and production states.
16 changes: 8 additions & 8 deletions scripts/update-helm-chart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
# SPDX-License-Identifier: MPL-2.0


CHART_DIR="charts/terraform-cloud-operator"
CHART_DIR="charts/hcp-terraform-operator"
CHART_FILE="Chart.yaml"

# Update the 'Chart.yaml' file with a new version of the Operator image tag.
function update_chart_file {
C_VERSION=`yq '.appVersion' $CHART_DIR/$CHART_FILE`
C_CHART_VERSION=`yq '.version' $CHART_DIR/$CHART_FILE`

if [[ $C_VERSION == $TFC_OPERATOR_RELEASE_VERSION && $C_CHART_VERSION == $TFC_OPERATOR_RELEASE_VERSION ]]; then
if [[ $C_VERSION == $HCP_TF_OPERATOR_RELEASE_VERSION && $C_CHART_VERSION == $HCP_TF_OPERATOR_RELEASE_VERSION ]]; then
echo "No changes in the $CHART_FILE file."
return 0
fi
Expand All @@ -20,24 +20,24 @@ function update_chart_file {

yq \
--inplace \
'.appVersion = strenv(TFC_OPERATOR_RELEASE_VERSION) | .version = strenv(TFC_OPERATOR_RELEASE_VERSION)' $CHART_DIR/$CHART_FILE
'.appVersion = strenv(HCP_TF_OPERATOR_RELEASE_VERSION) | .version = strenv(HCP_TF_OPERATOR_RELEASE_VERSION)' $CHART_DIR/$CHART_FILE
}

function main {
if [[ -z "${TFC_OPERATOR_RELEASE_VERSION}" ]]; then
echo "The environment variable TFC_OPERATOR_RELEASE_VERSION is not set."
if [[ -z "${HCP_TF_OPERATOR_RELEASE_VERSION}" ]]; then
echo "The environment variable HCP_TF_OPERATOR_RELEASE_VERSION is not set."
exit 1
fi

GIT_BRANCH=`git rev-parse --abbrev-ref HEAD | sed -e 's/^release\/v//'`

if [[ "$TFC_OPERATOR_RELEASE_VERSION" != "$GIT_BRANCH" ]]; then
echo "The version in the git branch name '${GIT_BRANCH}' does not match with the release version '${TFC_OPERATOR_RELEASE_VERSION}'."
if [[ "$HCP_TF_OPERATOR_RELEASE_VERSION" != "$GIT_BRANCH" ]]; then
echo "The version in the git branch name '${GIT_BRANCH}' does not match with the release version '${HCP_TF_OPERATOR_RELEASE_VERSION}'."
echo "Exiting!"
exit 1
fi

echo "Version: ${TFC_OPERATOR_RELEASE_VERSION}"
echo "Version: ${HCP_TF_OPERATOR_RELEASE_VERSION}"

update_chart_file
}
Expand Down

0 comments on commit 5207543

Please sign in to comment.