Skip to content

Commit

Permalink
add prepare-release make target (#5503)
Browse files Browse the repository at this point in the history
* add prepare-release make target

make prepare-release does the following:
- checks the local repository is clean
- search/replace PREVIOUS_VERSION with RELEASE_CANDIDATE
- runs make genotelcorecol
- creates a commit on a new branch
- runs make multimod-prerelease
- commits the changes to the branch
- creates a PR

* add check for gh
  • Loading branch information
Alex Boten authored Jul 15, 2022
1 parent 5f506a9 commit 7c125fb
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 11 deletions.
44 changes: 44 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ TOOLS_MOD_DIR := ./internal/tools

GOOS=$(shell $(GOCMD) env GOOS)
GOARCH=$(shell $(GOCMD) env GOARCH)
GH := $(shell which gh)

# TODO: Find a way to configure this in the generated code, currently no effect.
BUILD_INFO_IMPORT_PATH=go.opentelemetry.io/collector/internal/version
Expand Down Expand Up @@ -369,3 +370,46 @@ multimod-verify: install-tools
multimod-prerelease: install-tools
multimod prerelease -v ./versions.yaml -m collector-core
$(MAKE) gotidy

.PHONY: prepare-release
prepare-release:
ifdef PREVIOUS_VERSION
@echo "Previous version $(PREVIOUS_VERSION)"
else
@echo "PREVIOUS_VERSION not defined"
@echo "usage: make prepare-release RELEASE_CANDIDATE=<version eg 0.53.0> PREVIOUS_VERSION=<version eg 0.52.0>"
exit 1
endif
ifdef RELEASE_CANDIDATE
@echo "Preparing release $(RELEASE_CANDIDATE)"
else
@echo "RELEASE_CANDIDATE not defined"
@echo "usage: make prepare-release RELEASE_CANDIDATE=<version eg 0.53.0> PREVIOUS_VERSION=<version eg 0.52.0>"
exit 1
endif
# ensure a clean branch
git diff -s --exit-code || (echo "local repository not clean"; exit 1)
# TODO: update changelog
# update versions.yaml config.go builder-config.yaml
sed -i.bak 's/$(PREVIOUS_VERSION)/$(RELEASE_CANDIDATE)/g' versions.yaml
sed -i.bak 's/$(PREVIOUS_VERSION)/$(RELEASE_CANDIDATE)/g' ./cmd/builder/internal/builder/config.go
sed -i.bak 's/$(PREVIOUS_VERSION)/$(RELEASE_CANDIDATE)/g' ./cmd/otelcorecol/builder-config.yaml
sed -i.bak 's/$(PREVIOUS_VERSION)/$(RELEASE_CANDIDATE)/g' examples/k8s/otel-config.yaml
find . -name "*.bak" -type f -delete
# regenerate files
$(MAKE) genotelcorecol
# commit changes before running multimod
git checkout -b opentelemetry-collector-bot/release-$(RELEASE_CANDIDATE)
git add .
git commit -m "prepare release $(RELEASE_CANDIDATE)"
$(MAKE) multimod-prerelease
# commit multimod changes
git add .
git commit -m "add multimod changes" || (echo "no multimod changes to commit")
git push fork opentelemetry-collector-bot/release-$(RELEASE_CANDIDATE)
@if [ -z "$(GH)" ]; then \
echo "'gh' command not found, can't submit the PR on your behalf."; \
exit 1; \
fi
gh pr create --title "[chore] prepare release $(RELEASE_CANDIDATE)"

12 changes: 1 addition & 11 deletions docs/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,7 @@ It is possible that a core approver isn't a contrib approver. In that case, the

* Update CHANGELOG.md file and rename the Unreleased section to the new release name. Add a new unreleased section at top. Use commit history feature to get the list of commits since the last release to help understand what should be in the release notes, e.g.: https://github.com/open-telemetry/opentelemetry-collector/compare/v0.44.0...main.

* Use multimod to update the version of the collector package
* Update [versions.yaml](https://github.com/open-telemetry/opentelemetry-collector/blob/main/versions.yaml) and commit it locally
* Run `make multimod-prerelease` (it might fail if you didn't commit the change above)

* Update the collector version in the collector builder to the new release in `./cmd/builder/internal/builder/config.go`.

* Update the collector version in the manifest used by `make run` to the new release in `./cmd/otelcorecol/builder-config.yaml` and run `make genotelcorecol`.

* Update the collector version in the `examples/k8s/otel-config.yaml`

* Submit a PR with the changes and get the PR approved and merged.
* Run `make prepare-release PREVIOUS_VERSION=0.52.0 RELEASE_CANDIDATE=0.53.0`

* Ensure the `main` branch builds successfully.

Expand Down

0 comments on commit 7c125fb

Please sign in to comment.