-
Notifications
You must be signed in to change notification settings - Fork 501
ci: automate pre- and post-release version bump to include -DEV in main #3583 #3586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
asr-alurisanthoshreddy
wants to merge
10
commits into
open-telemetry:main
from
asr-alurisanthoshreddy:main
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
95e257f
ci: automate pre- and post-release version bump to include -DEV in main
asr-alurisanthoshreddy 2b7f89a
Update .github/workflows/post-release-bump.yml
asr-alurisanthoshreddy 3182129
Update .github/workflows/pre-release.yml
asr-alurisanthoshreddy 8d76249
Update .github/workflows/pre-release.yml
asr-alurisanthoshreddy 517122c
Update .github/workflows/pre-release.yml
asr-alurisanthoshreddy 0db4dcb
Update .github/workflows/post-release-bump.yml
asr-alurisanthoshreddy 704cfa1
Update .github/workflows/post-release-bump.yml
asr-alurisanthoshreddy a809720
Update post-release-bump.yml
asr-alurisanthoshreddy cdb44d6
Update version.h
asr-alurisanthoshreddy 49cf1ff
Update version.h
asr-alurisanthoshreddy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: Post-Release Version Bump | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*.*.*' | ||
|
||
jobs: | ||
bump-version: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout main branch | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: main | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract release version and decide bump type | ||
run: | | ||
TAG_VERSION="${GITHUB_REF#refs/tags/v}" | ||
echo "TAG_VERSION=$TAG_VERSION" >> $GITHUB_ENV | ||
MAJOR=$(echo "$TAG_VERSION" | cut -d. -f1) | ||
MINOR=$(echo "$TAG_VERSION" | cut -d. -f2) | ||
PATCH=$(echo "$TAG_VERSION" | cut -d. -f3) | ||
|
||
# Always bump minor version and reset patch | ||
NEW_MAJOR=$MAJOR | ||
NEW_MINOR=$((MINOR + 1)) | ||
NEW_PATCH=0 | ||
|
||
echo "NEW_MAJOR=$NEW_MAJOR" >> $GITHUB_ENV | ||
echo "NEW_MINOR=$NEW_MINOR" >> $GITHUB_ENV | ||
echo "NEW_PATCH=$NEW_PATCH" >> $GITHUB_ENV | ||
|
||
- name: Update version.h to DEV version | ||
run: | | ||
FILE_PATH="include/opentelemetry/version.h" | ||
sed -i "s|#define OPENTELEMETRY_VERSION \".*\"|#define OPENTELEMETRY_VERSION \"${NEW_MAJOR}.${NEW_MINOR}.${NEW_PATCH}-DEV\"|" "$FILE_PATH" | ||
sed -i "s|#define OPENTELEMETRY_VERSION_MAJOR .*|#define OPENTELEMETRY_VERSION_MAJOR ${NEW_MAJOR}|" "$FILE_PATH" | ||
sed -i "s|#define OPENTELEMETRY_VERSION_MINOR .*|#define OPENTELEMETRY_VERSION_MINOR ${NEW_MINOR}|" "$FILE_PATH" | ||
sed -i "s|#define OPENTELEMETRY_VERSION_PATCH .*|#define OPENTELEMETRY_VERSION_PATCH ${NEW_PATCH}|" "$FILE_PATH" | ||
|
||
- name: Commit and push changes | ||
run: | | ||
git config user.name "github-actions[bot]" | ||
git config user.email "github-actions[bot]@users.noreply.github.com" | ||
git add include/opentelemetry/version.h | ||
asr-alurisanthoshreddy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
git commit -m "Bump version to ${NEW_MAJOR}.${NEW_MINOR}.${NEW_PATCH}-DEV after release" || echo "No changes to commit" | ||
git push origin main |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: Pre-Release Preparation | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: 'Release version (e.g. 1.23.0)' | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
prepare-release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout main branch | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: main | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Validate current version contains -DEV | ||
run: | | ||
FILE_PATH="api/include/opentelemetry/version.h" | ||
if ! grep -q -- "-DEV" "$FILE_PATH"; then | ||
echo "Error: version.h does not contain -DEV. Aborting to prevent overwriting a release." | ||
exit 1 | ||
fi | ||
|
||
- name: Remove -DEV from version.h | ||
run: | | ||
FILE_PATH="api/include/opentelemetry/version.h" | ||
VERSION="${{ github.event.inputs.version }}" | ||
|
||
MAJOR=$(echo "$VERSION" | cut -d. -f1) | ||
MINOR=$(echo "$VERSION" | cut -d. -f2) | ||
PATCH=$(echo "$VERSION" | cut -d. -f3) | ||
|
||
sed -i "s|#define OPENTELEMETRY_VERSION \".*\"|#define OPENTELEMETRY_VERSION \"${VERSION}\"|" "$FILE_PATH" | ||
sed -i "s|#define OPENTELEMETRY_VERSION_MAJOR .*|#define OPENTELEMETRY_VERSION_MAJOR ${MAJOR}|" "$FILE_PATH" | ||
sed -i "s|#define OPENTELEMETRY_VERSION_MINOR .*|#define OPENTELEMETRY_VERSION_MINOR ${MINOR}|" "$FILE_PATH" | ||
sed -i "s|#define OPENTELEMETRY_VERSION_PATCH .*|#define OPENTELEMETRY_VERSION_PATCH ${PATCH}|" "$FILE_PATH" | ||
|
||
- name: Commit clean release version | ||
run: | | ||
git config user.name "github-actions[bot]" | ||
git config user.email "github-actions[bot]@users.noreply.github.com" | ||
git add api/include/opentelemetry/version.h | ||
git commit -m "Prepare release ${{ github.event.inputs.version }}" || echo "No changes to commit" | ||
git push origin main | ||
|
||
- name: Create and push tag | ||
run: | | ||
git tag -a "v${{ github.event.inputs.version }}" -m "Release v${{ github.event.inputs.version }}" | ||
git push origin "v${{ github.event.inputs.version }}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.