-
Notifications
You must be signed in to change notification settings - Fork 34
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
feature: add auto version bump after release #186
Merged
Xtansia
merged 2 commits into
opensearch-project:main
from
samuelorji:feature/auto-bump-versions
Oct 1, 2023
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 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,61 @@ | ||
name: Increment Version | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*.*.*' | ||
|
||
permissions: {} | ||
jobs: | ||
build: | ||
if: github.repository == 'opensearch-project/opensearch-rs' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: GitHub App token | ||
id: github_app_token | ||
uses: tibdex/[email protected] | ||
with: | ||
app_id: ${{ secrets.APP_ID }} | ||
private_key: ${{ secrets.APP_PRIVATE_KEY }} | ||
installation_id: 22958780 | ||
|
||
- uses: actions/checkout@v4 | ||
- name: Fetch and Update Version Information | ||
run: | | ||
TAG=$(echo "${GITHUB_REF#refs/*/v}") | ||
CURRENT_VERSION_ARRAY=($(echo "$TAG" | tr . '\n')) | ||
BASE=$(IFS=. ; echo "${CURRENT_VERSION_ARRAY[*]:0:2}") | ||
CURRENT_VERSION=$(IFS=. ; echo "${CURRENT_VERSION_ARRAY[*]:0:3}") | ||
CURRENT_VERSION_ARRAY[2]=$((CURRENT_VERSION_ARRAY[2]+1)) | ||
NEXT_VERSION=$(IFS=. ; echo "${CURRENT_VERSION_ARRAY[*]:0:3}") | ||
echo "TAG=$TAG" >> $GITHUB_ENV | ||
echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV | ||
echo "NEXT_VERSION=$NEXT_VERSION" >> $GITHUB_ENV | ||
echo "BASE=$BASE" >> $GITHUB_ENV | ||
|
||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ env.BASE }} | ||
token: ${{ steps.github_app_token.outputs.token }} | ||
|
||
- name: Increment Patch Version | ||
run: | | ||
echo Incrementing $CURRENT_VERSION to $NEXT_VERSION | ||
sed -i '' -e "s/^version = \"$CURRENT_VERSION\"/version = \"$NEXT_VERSION\"/g" opensearch/Cargo.toml | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Before actually making the changes to the |
||
sed -i '' -e "s/^version = \"$CURRENT_VERSION\"/version = \"$NEXT_VERSION\"/g" api_generator/Cargo.toml | ||
sed -i '' -e "s/^version = \"$CURRENT_VERSION\"/version = \"$NEXT_VERSION\"/g" yaml_test_runner/Cargo.toml | ||
|
||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v3 | ||
with: | ||
token: ${{ steps.github_app_token.outputs.token }} | ||
base: ${{ env.BASE }} | ||
branch: 'create-pull-request/patch- ${{ env.BASE }}' | ||
commit-message: Increment version to ${{ env.NEXT_VERSION }} | ||
signoff: true | ||
delete-branch: true | ||
labels: | | ||
autocut | ||
title: '[AUTO] Increment version to ${{ env.NEXT_VERSION }}.' | ||
body: | | ||
I've noticed that a new tag ${{ env.TAG }} was pushed, and incremented the version from ${{ env.CURRENT_VERSION }} to ${{ env.NEXT_VERSION }}. |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assumes that
$CURRENT_VERSION
is the recently released version and is what is already in Cargo.tomlThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or will it make sense to do a wildcard match:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leave this as
$CURRENT_VERSION
as a wildcard match like that could cause issues if we end up having a dependency definition in the below style: