Skip to content

Commit

Permalink
[chore] Add an automation to skip release if there no changes
Browse files Browse the repository at this point in the history
Update the release process to skip releasing the stable set of modules if there are no changes since the last version
  • Loading branch information
dmitryax committed Apr 25, 2023
1 parent 9257d7f commit a1db568
Show file tree
Hide file tree
Showing 9 changed files with 145 additions and 44 deletions.
26 changes: 14 additions & 12 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ on:
# the minor version number and set the patch number to 0.
inputs:
candidate-stable:
required: true
description: Release candidate version (stable, like 1.0.0-rc4)

current-stable:
required: true
description: Current version (stable, like 1.0.0-rc3)

candidate-beta:
required: true
description: Release candidate version (beta, like 0.70.0)

current-beta:
Expand All @@ -26,16 +24,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# To keep track of the progress, it might be helpful to create a tracking issue similar to #6067. You are responsible
# for all of the steps under the "Performed by collector release manager" heading. Once the issue is created, you can
# create the individual ones by hovering them and clicking the "Convert to issue" button on the right hand side.
- name: Create issue for tracking release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CANDIDATE_BETA: ${{ inputs.candidate-beta }}
CANDIDATE_STABLE: ${{ inputs.candidate-stable }}
REPO: open-telemetry/opentelemetry-collector
run: ./.github/workflows/scripts/release-create-tracking-issue.sh
with:
fetch-depth: 0
# Make sure that there are no open issues with release:blocker label in Core. The release has to be delayed until they are resolved.
- name: Check blockers in core
env:
Expand Down Expand Up @@ -77,3 +67,15 @@ jobs:
CURRENT_BETA: ${{ inputs.current-beta }}
CURRENT_STABLE: ${{ inputs.current-stable }}
run: ./.github/workflows/scripts/release-prepare-release.sh
# To keep track of the progress, it might be helpful to create a tracking issue similar to #6067. You are responsible
# for all of the steps under the "Performed by collector release manager" heading. Once the issue is created, you can
# create the individual ones by hovering them and clicking the "Convert to issue" button on the right hand side.
- name: Create issue for tracking release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CANDIDATE_BETA: ${{ inputs.candidate-beta }}
CANDIDATE_STABLE: ${{ inputs.candidate-stable }}
CURRENT_BETA: ${{ inputs.current-beta }}
CURRENT_STABLE: ${{ inputs.current-stable }}
REPO: open-telemetry/opentelemetry-collector
run: ./.github/workflows/scripts/release-create-tracking-issue.sh
20 changes: 14 additions & 6 deletions .github/workflows/scripts/release-create-tracking-issue.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
#!/bin/bash -ex

EXISTING_ISSUE=$( gh issue list --search "Release v${CANDIDATE_BETA}/v${CANDIDATE_STABLE}" --json url --jq '.[].url' --repo "${REPO}" )
STABLE="${CANDIDATE_STABLE}"
if [ "${STABLE}" == "" ]; then
STABLE="${CURRENT_STABLE}"
fi
BETA="${CANDIDATE_BETA}"
if [ "${BETA}" == "" ]; then
BETA="${CURRENT_BETA}"
fi
RELEASE_VERSION=v${STABLE}/v${BETA}

EXISTING_ISSUE=$( gh issue list --search "Release ${RELEASE_VERSION}" --json url --jq '.[].url' --repo "${REPO}" )

if [ "${EXISTING_ISSUE}" != "" ]; then
echo "Issue already exists: ${EXISTING_ISSUE}"
exit 0
fi

gh issue create -a "${GITHUB_ACTOR}" --repo "${REPO}" --label release --title "Release v${CANDIDATE_BETA}/v${CANDIDATE_STABLE}" --body "Like #4522, but for v${CANDIDATE_BETA}/v${CANDIDATE_STABLE}
gh issue create -a "${GITHUB_ACTOR}" --repo "${REPO}" --label release --title "Release ${RELEASE_VERSION}" --body "Like #4522, but for ${RELEASE_VERSION}
**Performed by collector release manager**
- [ ] Prepare stable core release v${CANDIDATE_STABLE}
- [ ] Prepare beta core release v${CANDIDATE_BETA}
- [ ] Tag and release stable core v${CANDIDATE_STABLE}
- [ ] Tag and release beta core v${CANDIDATE_BETA}
- [ ] Prepare core release ${RELEASE_VERSION}
- [ ] Tag and release core ${RELEASE_VERSION}
- [ ] Prepare contrib release v${CANDIDATE_BETA}
- [ ] Tag and release contrib v${CANDIDATE_BETA}
- [ ] Prepare otelcol-releases v${CANDIDATE_BETA}
Expand Down
33 changes: 26 additions & 7 deletions .github/workflows/scripts/release-prepare-release.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,39 @@
#!/bin/bash -ex

make chlog-update VERSION="v${CANDIDATE_STABLE}/v${CANDIDATE_BETA}"
if [ "${CANDIDATE_STABLE}" == "" ] && [ "${CANDIDATE_BETA}" == "" ]; then
echo "One of CANDIDATE_STABLE or CANDIDATE_BETA must be set"
exit 1
fi

STABLE="${CANDIDATE_STABLE}"
if [ "${STABLE}" == "" ]; then
STABLE="${CURRENT_STABLE}"
fi
BETA="${CANDIDATE_BETA}"
if [ "${BETA}" == "" ]; then
BETA="${CURRENT_BETA}"
fi
RELEASE_VERSION=v${STABLE}/v${BETA}

make chlog-update VERSION="${RELEASE_VERSION}"
git config user.name opentelemetrybot
git config user.email 107717825+opentelemetrybot@users.noreply.github.com
BRANCH="prepare-release-prs/${CANDIDATE_BETA}-${CANDIDATE_STABLE}"
BRANCH="prepare-release-prs/${CANDIDATE_BETA}"
git checkout -b "${BRANCH}"
git add --all
git commit -m "Changelog update ${CANDIDATE_BETA}/${CANDIDATE_STABLE}"
git commit -m "Changelog update ${RELEASE_VERSION}"

make prepare-release GH=none PREVIOUS_VERSION="${CURRENT_STABLE}" RELEASE_CANDIDATE="${CANDIDATE_STABLE}" MODSET=stable
make prepare-release GH=none PREVIOUS_VERSION="${CURRENT_BETA}" RELEASE_CANDIDATE="${CANDIDATE_BETA}" MODSET=beta
if [ "${CANDIDATE_STABLE}" != "" ]; then
make prepare-release GH=none PREVIOUS_VERSION="${CURRENT_STABLE}" RELEASE_CANDIDATE="${CANDIDATE_STABLE}" MODSET=stable
fi
if [ "${CANDIDATE_BETA}" != "" ]; then
make prepare-release GH=none PREVIOUS_VERSION="${CURRENT_BETA}" RELEASE_CANDIDATE="${CANDIDATE_BETA}" MODSET=beta
fi
git push origin "${BRANCH}"

gh pr create --title "[chore] Prepare release ${CANDIDATE_BETA}/${CANDIDATE_STABLE}" --body "
gh pr create --title "[chore] Prepare release ${RELEASE_VERSION}" --body "
The following commands were run to prepare this release:
- make chlog-update VERSION=v${CANDIDATE_BETA}/v${CANDIDATE_STABLE}
- make chlog-update VERSION=${RELEASE_VERSION}
- make prepare-release GH=none PREVIOUS_VERSION=${CURRENT_STABLE} RELEASE_CANDIDATE=${CANDIDATE_STABLE} MODSET=stable
- make prepare-release GH=none PREVIOUS_VERSION=${CURRENT_BETA} RELEASE_CANDIDATE=${CANDIDATE_BETA} MODSET=beta
"
33 changes: 33 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,36 @@ push-tags: $(MULTIMOD)
git push ${REMOTE} $${tag}; \
done;

.PHONY: check-changes
check-changes: $(YQ)
ifndef MODSET
@echo "MODSET not defined"
@echo "usage: make check-changes PREVIOUS_VERSION=<version eg 0.52.0> MODSET=beta"
exit 1
endif
ifndef PREVIOUS_VERSION
@echo "PREVIOUS_VERSION not defined"
@echo "usage: make check-changes PREVIOUS_VERSION=<version eg 0.52.0> MODSET=beta"
exit 1
endif
@all_submods=$$($(YQ) e '.module-sets.*.modules[] | select(. != "go.opentelemetry.io/collector")' versions.yaml | sed 's/^go\.opentelemetry\.io\/collector\///'); \
mods=$$($(YQ) e '.module-sets.$(MODSET).modules[]' versions.yaml | sed 's/^go\.opentelemetry\.io\/collector\///'); \
changed_files=""; \
for mod in $${mods}; do \
if [ "$${mod}" == "go.opentelemetry.io/collector" ]; then \
changed_files+=$$(git diff --name-only v$(PREVIOUS_VERSION) -- $$(printf '%s\n' $${all_submods[@]} | sed 's/^/:!/' | paste -sd' ' -) | grep -E '.+\.go$$'); \
else \
changed_files+=$$(git diff --name-only $${mod}/v$(PREVIOUS_VERSION) -- $${mod} | grep -E '.+\.go$$'); \
fi; \
done; \
if [ -n "$${changed_files}" ]; then \
echo "The following files changed in $(MODSET) modules since v$(PREVIOUS_VERSION): $${changed_files}"; \
else \
echo "No $(MODSET) modules have changed since v$(PREVIOUS_VERSION)"; \
echo "No need to release $(MODSET)."; \
exit 1; \
fi

.PHONY: prepare-release
prepare-release:
ifndef MODSET
Expand All @@ -404,6 +434,9 @@ else
endif
# ensure a clean branch
git diff -s --exit-code || (echo "local repository not clean"; exit 1)
# check if any modules have changed since the previous release
$(MAKE) check-changes
# update files with new version
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/builder/test/core.builder.yaml
Expand Down
29 changes: 16 additions & 13 deletions Makefile.Common
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,8 @@ GOARCH := $(shell $(GOCMD) env GOARCH)
TOOLS_MOD_DIR := $(PWD)/internal/tools
TOOLS_BIN_DIR := $(PWD)/.tools
TOOLS_MOD_REGEX := "\s+_\s+\".*\""
TOOLS_PKG_NAMES := $(shell grep -E $(TOOLS_MOD_REGEX) < $(TOOLS_MOD_DIR)/tools.go | tr -d " _\"")
TOOLS_BIN_NAMES := $(addprefix $(TOOLS_BIN_DIR)/, $(notdir $(TOOLS_PKG_NAMES)))


.PHONY: install-tools
install-tools: $(TOOLS_BIN_NAMES)

$(TOOLS_BIN_DIR):
mkdir -p $@

$(TOOLS_BIN_NAMES): $(TOOLS_BIN_DIR) $(TOOLS_MOD_DIR)/go.mod
cd $(TOOLS_MOD_DIR) && $(GOCMD) build -o $@ -trimpath $(filter %/$(notdir $@),$(TOOLS_PKG_NAMES))
TOOLS_PKG_NAMES := $(shell grep -E $(TOOLS_MOD_REGEX) < $(TOOLS_MOD_DIR)/tools.go | tr -d " _\"" | grep -vE '/v[0-9]+$$')
TOOLS_BIN_NAMES := $(addprefix $(TOOLS_BIN_DIR)/, $(notdir $(shell echo $(TOOLS_PKG_NAMES))))

ADDLICENSE := $(TOOLS_BIN_DIR)/addlicense
APIDIFF := $(TOOLS_BIN_DIR)/apidiff
Expand All @@ -33,12 +23,25 @@ GOCOVMERGE := $(TOOLS_BIN_DIR)/gocovmerge
GOIMPORTS := $(TOOLS_BIN_DIR)/goimports
LINT := $(TOOLS_BIN_DIR)/golangci-lint
IMPI := $(TOOLS_BIN_DIR)/impi
MISSPELL := $(TOOLS_BIN_DIR)/misspell
MISSPELL := $(TOOLS_BIN_DIR)/misspell
MULTIMOD := $(TOOLS_BIN_DIR)/multimod
PORTO := $(TOOLS_BIN_DIR)/porto
YQ := $(TOOLS_BIN_DIR)/yq

GH := $(shell which gh)

.PHONY: install-tools
install-tools: $(TOOLS_BIN_NAMES) $(YQ)

$(TOOLS_BIN_DIR):
mkdir -p $@

$(TOOLS_BIN_NAMES): $(TOOLS_BIN_DIR) $(TOOLS_MOD_DIR)/go.mod
cd $(TOOLS_MOD_DIR) && $(GOCMD) build -o $@ -trimpath $(filter %/$(notdir $@),$(TOOLS_PKG_NAMES))

$(YQ): $(TOOLS_BIN_DIR) $(TOOLS_MOD_DIR)/go.mod
cd $(TOOLS_MOD_DIR) && $(GOCMD) build -o $@ -trimpath github.com/mikefarah/yq/v4

.PHONY: test
test:
$(GOTEST) $(GOTEST_OPT) ./...
Expand Down
3 changes: 2 additions & 1 deletion docs/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ It is possible that a core approver isn't a contrib approver. In that case, the

## Releasing opentelemetry-collector

1. Determine the version number that will be assigned to the release. During the beta phase, we increment the minor version number and set the patch number to 0. In this document, we are using `v0.55.0` as the version to be released, following `v0.54.0`.
1. Determine the version number that will be assigned to the release. During the beta phase, we increment the minor version number and set the patch number to 0. In this document, we are using `v0.55.0` as the version to be released, following `v0.54.0`.
Check if stable modules have any changes since the last release by reunning `make check-changes PREVIOUS_VERSION=v1.0.0-rc9 MODSET=stable`. If there are no changes, there is no need to release new version for stable modules.

2. Run the action [Automation - Prepare Release](https://github.com/open-telemetry/opentelemetry-collector/actions/workflows/prepare-release.yml). This will create an issue to track the progress of the release and a pull request to update the changelog and version numbers in the repo.

Expand Down
14 changes: 12 additions & 2 deletions internal/tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
github.com/golangci/golangci-lint v1.52.2
github.com/google/addlicense v1.1.1
github.com/jcchavezs/porto v0.4.0
github.com/mikefarah/yq/v4 v4.33.3
github.com/ory/go-acc v0.2.8
github.com/pavius/impi v0.0.3
github.com/wadey/gocovmerge v0.0.0-20160331181800-b5bfa59ec0ad
Expand All @@ -32,7 +33,9 @@ require (
github.com/Microsoft/go-winio v0.5.2 // indirect
github.com/OpenPeeDeeP/depguard v1.1.1 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 // indirect
github.com/a8m/envsubst v1.4.2 // indirect
github.com/acomagu/bufpipe v1.0.4 // indirect
github.com/alecthomas/participle/v2 v2.0.0 // indirect
github.com/alexkohler/prealloc v1.0.0 // indirect
github.com/alingse/asasalint v0.0.11 // indirect
github.com/ashanbrown/forbidigo v1.5.1 // indirect
Expand All @@ -55,6 +58,8 @@ require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/denis-tingaikin/go-header v0.4.3 // indirect
github.com/dgraph-io/ristretto v0.0.2 // indirect
github.com/dimchansky/utfbom v1.1.1 // indirect
github.com/elliotchance/orderedmap v1.5.0 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/esimonov/ifshort v1.0.4 // indirect
github.com/ettle/strcase v0.1.1 // indirect
Expand All @@ -76,6 +81,8 @@ require (
github.com/go-toolsmith/typep v1.1.0 // indirect
github.com/go-xmlfmt/xmlfmt v1.1.2 // indirect
github.com/gobwas/glob v0.2.3 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/goccy/go-yaml v1.11.0 // indirect
github.com/gofrs/flock v0.8.1 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golangci/check v0.0.0-20180506172741-cfe4005ccda2 // indirect
Expand Down Expand Up @@ -104,6 +111,7 @@ require (
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/jgautheron/goconst v1.5.1 // indirect
github.com/jingyugao/rowserrcheck v1.1.1 // indirect
github.com/jinzhu/copier v0.3.5 // indirect
github.com/jirfag/go-printf-func-name v0.0.0-20200119135958-7558a9eaa5af // indirect
github.com/julz/importas v0.1.0 // indirect
github.com/junk1tm/musttag v0.5.0 // indirect
Expand Down Expand Up @@ -140,7 +148,7 @@ require (
github.com/ory/viper v1.7.5 // indirect
github.com/pborman/uuid v1.2.0 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/pelletier/go-toml/v2 v2.0.7 // indirect
github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/polyfloyd/go-errorlint v1.4.0 // indirect
Expand Down Expand Up @@ -196,15 +204,17 @@ require (
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/crypto v0.6.0 // indirect
golang.org/x/crypto v0.7.0 // indirect
golang.org/x/exp/typeparams v0.0.0-20230224173230-c95f2b4c22f2 // indirect
golang.org/x/mod v0.10.0 // indirect
golang.org/x/net v0.9.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.7.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/op/go-logging.v1 v1.0.0-20160211212156-b2cb9fa56473 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
Loading

0 comments on commit a1db568

Please sign in to comment.