Skip to content

Commit fef33e9

Browse files
jackgopack4mx-psi
andauthored
[chore] [OTEL-2623] Automate Release Step 4 - push branch (open-telemetry#13040)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description <!-- Issue number if applicable --> #### Link to tracking issue Fixes [open-telemetry#12989](open-telemetry#12989) <!--Describe what testing was performed and which tests were added.--> #### Testing Sample release (bugfix and new version) in jackgopack4 fork. - [v0.126.1 workflow success](https://github.com/jackgopack4/opentelemetry-collector/actions/runs/15048048531/job/42295539150) - [v0.126.1 release after pushing tags locally](https://github.com/jackgopack4/opentelemetry-collector/releases/tag/v0.126.1) - [v0.127.0 workflow success](https://github.com/jackgopack4/opentelemetry-collector/actions/runs/15048921462/job/42298512054) - [v0.127.0 release after pushing tags locally](https://github.com/jackgopack4/opentelemetry-collector/releases/tag/v0.127.0) <!--Describe the documentation added.--> #### Documentation Update release.md in docs folder to reflect step 4 (and ability to run as workflow or local bash script). <!--Please delete paragraphs that you did not use before submitting.--> --------- Co-authored-by: Pablo Baeyens <[email protected]>
1 parent dc3f5d2 commit fef33e9

File tree

3 files changed

+126
-10
lines changed

3 files changed

+126
-10
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Automation - Release Branch
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release-series:
7+
description: 'Release series (e.g., v0.85.x).'
8+
required: true
9+
prepare-release-commit-hash:
10+
description: 'Commit hash for "Prepare release" commit (e.g., a1b2c3d4)'
11+
required: true
12+
13+
jobs:
14+
release-branch:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: write
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Setup Go
25+
uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0
26+
with:
27+
go-version: 1.23.9
28+
29+
- name: Setup Git config
30+
run: |
31+
git config --global user.name "opentelemetrybot"
32+
git config --global user.email "[email protected]"
33+
34+
- name: Run release-branch.sh
35+
run: |
36+
./.github/workflows/scripts/release-branch.sh "${{ inputs.release-series }}" "${{ inputs.prepare-release-commit-hash }}"
37+
env:
38+
UPSTREAM_REMOTE_NAME: "origin"
39+
MAIN_BRANCH_NAME: "main"
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#!/bin/bash -ex
2+
#
3+
# Copyright The OpenTelemetry Authors
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
# --- Configuration ---
7+
RELEASE_SERIES="$1" # e.g., v0.85.x
8+
PREPARE_RELEASE_COMMIT_HASH="$2" # Optional: Specific commit hash for "Prepare release"
9+
UPSTREAM_REMOTE_NAME=${UPSTREAM_REMOTE_NAME:-"upstream"} # Your upstream remote name for open-telemetry/opentelemetry-collector
10+
MAIN_BRANCH_NAME=${MAIN_BRANCH_NAME:-"main"}
11+
LOCAL_MAIN_BRANCH_NAME=${LOCAL_MAIN_BRANCH_NAME:-"${MAIN_BRANCH_NAME}"}
12+
# These variables are only used if git user.name and git user.email are not configured
13+
GIT_CONFIG_USER_NAME=${GIT_CONFIG_USER_NAME:-"opentelemetrybot"}
14+
GIT_CONFIG_USER_EMAIL=${GIT_CONFIG_USER_EMAIL:-"[email protected]"}
15+
16+
# --- Validate Input ---
17+
if [[ -z "$RELEASE_SERIES" || -z "$PREPARE_RELEASE_COMMIT_HASH" ]]; then
18+
echo "Error: Both release series and prepare release commit hash must be provided."
19+
echo "Usage: $0 <release-series> <prepare-release-commit-hash>"
20+
echo "Example: $0 v0.85.x a1b2c3d4"
21+
exit 1
22+
fi
23+
24+
RELEASE_BRANCH_NAME="release/${RELEASE_SERIES}"
25+
26+
echo "Automating Release Steps for: ${RELEASE_SERIES}"
27+
echo "Release Branch Name: ${RELEASE_BRANCH_NAME}"
28+
echo "'Prepare release' commit hash: ${PREPARE_RELEASE_COMMIT_HASH}"
29+
echo "Upstream Remote: ${UPSTREAM_REMOTE_NAME}"
30+
echo "--------------------------------------------------"
31+
32+
# --- Step 4: Checkout main, Pull, Create/Update and Push Release Branch ---
33+
echo ""
34+
echo "=== Step 4: Preparing and Pushing Release Branch ==="
35+
36+
# 1. Checkout main
37+
git checkout "${LOCAL_MAIN_BRANCH_NAME}"
38+
39+
# 2. Fetch from upstream (updates remote-tracking branches including potential existing release branch)
40+
git fetch "${UPSTREAM_REMOTE_NAME}"
41+
42+
# 3. Rebase local main with upstream/main
43+
git rebase "${UPSTREAM_REMOTE_NAME}/${MAIN_BRANCH_NAME}"
44+
echo "'${LOCAL_MAIN_BRANCH_NAME}' branch is now up-to-date."
45+
46+
# Verify the commit exists (it should be reachable from main after fetch)
47+
if ! git cat-file -e "${PREPARE_RELEASE_COMMIT_HASH}^{commit}" 2>/dev/null; then
48+
echo "Error: Provided 'Prepare release' commit hash '${PREPARE_RELEASE_COMMIT_HASH}' not found."
49+
exit 1
50+
fi
51+
# 4. Handle Release Branch: Check existence, create or switch, and merge/base
52+
BRANCH_EXISTS_LOCALLY=$(git branch --list "${RELEASE_BRANCH_NAME}")
53+
# Check remote by looking for the remote tracking branch ref after fetch
54+
if git rev-parse --verify --quiet "${UPSTREAM_REMOTE_NAME}/${RELEASE_BRANCH_NAME}" > /dev/null 2>&1; then
55+
BRANCH_EXISTS_REMOTELY=true
56+
fi
57+
58+
if [[ -n "$BRANCH_EXISTS_LOCALLY" ]]; then
59+
echo "Release branch '${RELEASE_BRANCH_NAME}' found locally."
60+
echo "Please delete local release branch using 'git branch -D ${RELEASE_BRANCH_NAME}' and run the script again."
61+
exit 1
62+
elif [[ -n "$BRANCH_EXISTS_REMOTELY" ]]; then
63+
echo "Release branch '${RELEASE_BRANCH_NAME}' found on remote '${UPSTREAM_REMOTE_NAME}'."
64+
echo "Nothing to do, exiting."
65+
exit 0
66+
else
67+
echo "Release branch '${RELEASE_BRANCH_NAME}' not found locally or on remote."
68+
git switch -c "${RELEASE_BRANCH_NAME}" "${TARGET_MAIN_STATE_COMMIT}"
69+
fi
70+
71+
echo "Current branch is now '${RELEASE_BRANCH_NAME}'."
72+
git --no-pager log -1 --pretty=oneline # Show the commit at the tip of the release branch
73+
74+
# 5. Push the release branch to upstream
75+
git push -u "${UPSTREAM_REMOTE_NAME}" "${RELEASE_BRANCH_NAME}"
76+
echo "Branch '${RELEASE_BRANCH_NAME}' pushed (or updated) on '${UPSTREAM_REMOTE_NAME}'."
77+
echo "Step 4 completed."
78+
echo "--------------------------------------------------"
79+
80+
echo ""
81+
echo "Automation for your Step 4 (push release/<release-series> branch) complete."
82+
echo "Next, you would typically proceed to your Step 5 on your local machine."
83+
echo "You will need to check out the release branch locally and push beta/stable tags."

docs/release.md

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,11 @@ Before the release, make sure there are no open release blockers in [core](https
4545
- If the PR needs updated in any way you can make the changes in a fork and PR those changes into the `prepare-release-prs/x` branch. You do not need to wait for the CI to pass in this prep-to-prep PR.
4646
- 🛑 **Do not move forward until this PR is merged.** 🛑
4747

48-
4. Check out main and ensure it has the "Prepare release" commit in your local
49-
copy by pulling in the latest from `open-telemetry/opentelemetry-collector`
50-
Use this commit to create a branch named `release/<release-series>` (e.g.
51-
`release/v0.85.x`). Push the new branch to
52-
`open-telemetry/opentelemetry-collector`. Assuming your upstream remote is
53-
named `upstream`, you can try the following commands:
54-
- `git checkout main && git fetch upstream && git rebase upstream/main`
55-
- `git switch -c release/<release series>` # append the commit hash of the PR in the last step if it is not the head of mainline
56-
- `git push -u upstream release/<release series>`
48+
4. Manually run the action [Automation - Release Branch](https://github.com/open-telemetry/opentelemetry-collector/actions/workflows/release-branch.yml). This action will create a new branch (for a new release, e.g. `v0.127.0`). Bugfix releases are currently out of scope for this action/script.
49+
- Make sure to specify `v0.BETA.x` release-series argument (e.g. `v0.127.x`).
50+
- If the above does not work, the underlying script (./.github/workflows/scripts/release-branch.sh) can be tested and run locally passing appropriate variables and arguments for upstream name, release series, etc.
5751

58-
5. Make sure you are on `release/<release-series>`. Tag the module groups with the new release version by running:
52+
5. On your local machine, make sure have pulled `release/<release-series>` that was created on upstream in step 4. Tag the module groups with the new release version by running:
5953

6054
⚠️ If you set your remote using `https` you need to include `REMOTE=https://github.com/open-telemetry/opentelemetry-collector.git` in each command. ⚠️
6155

0 commit comments

Comments
 (0)