Skip to content

Commit adc1d0a

Browse files
authored
[chore] Automate release branch creation on tag push (#13240)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Automates release branch creation on `make push-tags` <!-- Issue number if applicable --> #### Link to tracking issue Relates to #11626 Follow-up on #13040 <!--Describe what testing was performed and which tests were added.--> #### Testing Two sample release in local repo (first bugfix then full version) - v0.128.1 [workflow](https://github.com/DataDog/opentelemetry-collector/actions/runs/15781766998) and [release](https://github.com/DataDog/opentelemetry-collector/releases/tag/v0.128.1) - v0.129.0 [workflow](https://github.com/DataDog/opentelemetry-collector/actions/runs/15781924053) and [release](https://github.com/DataDog/opentelemetry-collector/releases/tag/v0.129.0) <!--Describe the documentation added.--> #### Documentation Updated `release.md` <!--Please delete paragraphs that you did not use before submitting.--> #### Additional info Once this is accepted and merged in core, will propose one PR to combine #13040 and this change in contrib
1 parent 1440a98 commit adc1d0a

File tree

4 files changed

+43
-25
lines changed

4 files changed

+43
-25
lines changed

.github/workflows/release-branch.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
name: Automation - Release Branch
22

33
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
4+
push:
5+
tags:
6+
# Trigger on beta version tags (0.x.x series) to create release branch
7+
# This pattern matches: v0.{minor}.{patch} for new releases and bugfix releases
8+
- 'v0.[0-9]+.[0-9]+'
9+
- 'v0.[0-9]+.[0-9]+-*' # Also support release candidates if needed
1210

1311
jobs:
1412
release-branch:
@@ -33,7 +31,8 @@ jobs:
3331
3432
- name: Run release-branch.sh
3533
run: |
36-
./.github/workflows/scripts/release-branch.sh "${{ inputs.release-series }}" "${{ inputs.prepare-release-commit-hash }}"
34+
./.github/workflows/scripts/release-branch.sh
3735
env:
3836
UPSTREAM_REMOTE_NAME: "origin"
3937
MAIN_BRANCH_NAME: "main"
38+
GITHUB_REF: ${{ github.ref }}

.github/workflows/scripts/release-branch.sh

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,35 @@
44
# SPDX-License-Identifier: Apache-2.0
55

66
# --- Configuration ---
7-
RELEASE_SERIES="$1" # e.g., v0.85.x
8-
PREPARE_RELEASE_COMMIT_HASH="$2" # Optional: Specific commit hash for "Prepare release"
97
UPSTREAM_REMOTE_NAME=${UPSTREAM_REMOTE_NAME:-"upstream"} # Your upstream remote name for open-telemetry/opentelemetry-collector
108
MAIN_BRANCH_NAME=${MAIN_BRANCH_NAME:-"main"}
119
LOCAL_MAIN_BRANCH_NAME=${LOCAL_MAIN_BRANCH_NAME:-"${MAIN_BRANCH_NAME}"}
1210
# These variables are only used if git user.name and git user.email are not configured
1311
GIT_CONFIG_USER_NAME=${GIT_CONFIG_USER_NAME:-"opentelemetrybot"}
1412
GIT_CONFIG_USER_EMAIL=${GIT_CONFIG_USER_EMAIL:-"[email protected]"}
1513

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"
14+
# --- Extract release information from tag ---
15+
if [[ -z "$GITHUB_REF" ]]; then
16+
echo "Error: GITHUB_REF environment variable must be provided when running in GitHub Actions."
17+
echo "For manual usage: GITHUB_REF=refs/tags/v0.85.0 $0"
2118
exit 1
2219
fi
2320

21+
# Extract tag name and validate format using regex
22+
if [[ ! $GITHUB_REF =~ ^refs/tags/v([0-9]+\.[0-9]+)\.[0-9]+(-.+)?$ ]]; then
23+
echo "Error: GITHUB_REF did not match expected format (refs/tags/vX.XX.X)"
24+
exit 1
25+
fi
26+
27+
# Extract version numbers from regex match
28+
VERSION_MAJOR_MINOR=${BASH_REMATCH[1]}
29+
RELEASE_SERIES="v${VERSION_MAJOR_MINOR}.x"
30+
echo "Release series: ${RELEASE_SERIES}"
31+
32+
# --- Use current commit as prepare release commit ---
33+
PREPARE_RELEASE_COMMIT_HASH="${GITHUB_SHA:-HEAD}"
34+
echo "Using current commit as prepare release commit: ${PREPARE_RELEASE_COMMIT_HASH}"
35+
2436
RELEASE_BRANCH_NAME="release/${RELEASE_SERIES}"
2537

2638
echo "Automating Release Steps for: ${RELEASE_SERIES}"
@@ -78,6 +90,6 @@ echo "Step 4 completed."
7890
echo "--------------------------------------------------"
7991

8092
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."
93+
echo "Automation for release branch creation complete."
94+
echo "Release branch '${RELEASE_BRANCH_NAME}' has been created from the prepare release commit."
95+
echo "Tag-triggered build workflows should now be running for the pushed tags."

.github/workflows/sourcecode-release.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ on:
88
jobs:
99
goreleaser:
1010
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write # Grant write permissions to repository contents
1113
steps:
1214
- name: Checkout Repo
1315
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

docs/release.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,23 @@ 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. 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.
51-
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:
48+
4. On your local machine, make sure you are on the `main` branch and that the PR from step 3 is incorporated **at the head of your branch** (this is required to ensure the proper commit is used for the release tags and branch creation below). Tag the module groups with the new release version by running:
5349

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

5652
- `make push-tags MODSET=beta` for the beta modules group,
5753
- `make push-tags MODSET=stable` for the stable modules group, only if there were changes since the last release.
5854

59-
6. Wait for the new tag build to pass successfully.
55+
**Note**: Pushing the **beta** tags will automatically trigger the [Automation - Release Branch](https://github.com/open-telemetry/opentelemetry-collector/actions/workflows/release-branch.yml) GitHub Action, which will create the release branch (e.g. `release/v0.127.x`) from the commit that prepared the release. Pushing stable tags, if required, will not trigger creation of an additional release branch.
56+
57+
5. Wait for the "Automation - Release Branch" workflow to complete successfully. This workflow will automatically:
58+
- Detect the version from the pushed beta tags
59+
- Use the commit on which the tags were pushed as the "prepare release" commit
60+
- Create a new release branch (e.g. `release/v0.127.x`) from that commit
61+
62+
If the workflow fails, you can check the [Actions tab](https://github.com/open-telemetry/opentelemetry-collector/actions) for details. The underlying script (./.github/workflows/scripts/release-branch.sh) can also be tested and run locally if needed by setting the GITHUB_REF environment variable (e.g., `GITHUB_REF=refs/tags/v0.85.0 ./.github/workflows/scripts/release-branch.sh`).
63+
64+
6. Wait for the tag-triggered build workflows to pass successfully.
6065

6166
7. A new `v0.85.0` source code release should be automatically created on Github by now. Its description should already contain the corresponding CHANGELOG.md and CHANGELOG-API.md contents.
6267

0 commit comments

Comments
 (0)