-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add bump2version #151
Merged
Merged
Add bump2version #151
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
31f6029
Add bump2version
jashparekh 38c4d77
Add python 3.10 support
jashparekh 94ee19c
Update devbox image
jashparekh ade862e
Add docs
8bf675d
Update dependabot.yml
jashparekh 06c2941
Temp
e14303b
Merge branch 'add_bump2version' of github.com:jashparekh/pygitops int…
f74d721
Revert Py3.10
9047c43
Fix typo
1909a50
Only allow {major}.{minor}.{patch} versions
f7a47e2
Only allow {major}.{minor}.{patch} versions
6f8c175
Merge branch 'main' into add_bump2version
jashparekh c0d5d1a
Update bump_version.sh
jashparekh 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,12 @@ | ||
[bumpversion] | ||
current_version = 0.13.0 | ||
commit = True | ||
tag = False | ||
|
||
[bumpversion:file:docs/index.md] | ||
search = pygitops - {current_version} | ||
replace = pygitops - {new_version} | ||
|
||
[bumpversion:file:setup.cfg] | ||
search = version = {current_version} | ||
replace = version = {new_version} |
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
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,36 @@ | ||
name: Version Bump merged | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- "closed" | ||
branches: | ||
- "main" | ||
|
||
jobs: | ||
trigger-release: | ||
runs-on: ubuntu-latest | ||
if: github.event.pull_request.merged && | ||
startsWith(github.head_ref, 'bump_version_to_') && | ||
startsWith(github.event.pull_request.title, 'Bump version') && | ||
contains(github.event.pull_request.title, ' → ') | ||
environment: Create Release | ||
steps: | ||
- name: Get new version | ||
id: get-new-version | ||
run: | | ||
NEW_VERSION=$(echo ${{ github.head_ref }} | cut -d _ -f4 ) | ||
echo "::set-output name=version::$NEW_VERSION" | ||
- name: Is prerelease? | ||
id: is-prerelease | ||
run: | | ||
IS_PRERELEASE=$([[ "${{ steps.get-new-version.outputs.version }}" == *-[a-z]* ]] && echo true || echo false) | ||
echo "::set-output name=result::$IS_PRERELEASE" | ||
- name: Create Release | ||
# use hash for security since this has access to the access token | ||
uses: ncipollo/release-action@880be3d0a71bc0fa98db60201d2cbdc27324f547 # v1.8.6 | ||
jdw6359 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
with: | ||
token: ${{ secrets.ACCESS_TOKEN }} | ||
tag: v${{ steps.get-new-version.outputs.version }} | ||
name: v${{ steps.get-new-version.outputs.version }} Release | ||
commit: main |
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
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,57 @@ | ||
#!/usr/bin/env bash | ||
jdw6359 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# Referenced From: https://github.com/wayfair-incubator/columbo/blob/main/docker/bump_version.sh | ||
|
||
set -eo pipefail | ||
|
||
DEFAULT_BRANCH="main" | ||
|
||
function usage() { | ||
echo "usage: bump_version.sh major|minor|patch" | ||
echo "" | ||
echo " major|minor|patch : Part of version string to updated." | ||
exit 1 | ||
} | ||
|
||
if [[ $# != 1 || ! "${1}" =~ major|minor|patch ]]; then | ||
usage | ||
else | ||
PART="${1}" | ||
fi | ||
|
||
CURRENT_BRANCH=$(git branch --show-current) | ||
CURRENT_STATUS=$(git status --short --untracked-files=no) | ||
|
||
if [[ "${CURRENT_BRANCH}" != "${DEFAULT_BRANCH}" ]]; then | ||
echo "A version bump must be run from the default branch." | ||
echo "Run 'git switch ${DEFAULT_BRANCH}'" | ||
exit 2 | ||
elif [[ "$CURRENT_STATUS" != "" ]]; then | ||
echo "The working tree has uncommitted changes." | ||
echo "Commit or stash the changes before running a version bump." | ||
exit 3 | ||
fi | ||
# Ensure on default branch | ||
git switch --no-guess main | ||
# Capture value of new version | ||
NEW_VERSION=$(bump2version --dry-run --list "${PART}" | grep new_version | sed -r s,"^.*=",,) | ||
# Create bump branch | ||
BUMP_BRANCH_NAME="bump_version_to_${NEW_VERSION}" | ||
git switch -c "${BUMP_BRANCH_NAME}" | ||
# Update files | ||
bump2version "${PART}" | ||
|
||
# Updating the changelog has to be done manually | ||
# - bump2version doesn't support inserting dates https://github.com/c4urself/bump2version/issues/133 | ||
# - It is not possible to have a multiline string in an INI file where a line after the first line starts with '#'. | ||
# The config parser reads it as a comment line. | ||
TODAY=$(date +%Y-%m-%d) | ||
sed -i "s/## \[Unreleased\]/## \[Unreleased\]\n\n## \[${NEW_VERSION}\] - ${TODAY}/g" CHANGELOG.md | ||
|
||
# Add changelog to bump commit | ||
git add CHANGELOG.md | ||
git commit --amend --no-edit | ||
# Show effected files | ||
git show --pretty="" --name-only | ||
|
||
echo "Run 'git push --set-upstream origin ${BUMP_BRANCH_NAME}' to " |
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
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
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
bandit==1.7.0 | ||
black==21.9b0 | ||
bump2version==1.0.1 | ||
flake8==3.9.2 | ||
isort==5.9.3 | ||
mypy==0.910 | ||
|
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.
nice!