-
Notifications
You must be signed in to change notification settings - Fork 1
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
New Actions And Workflow for bumping version #136
base: main
Are you sure you want to change the base?
Changes from all commits
0375c17
a0416c6
82db094
99c4971
78b45d4
54c86f7
d0d3c60
0b030f3
7a76951
2c7f4c0
a2a3e0c
5eea497
43f8923
fbfe193
c12b090
eda6cff
e592eec
f1bc6f0
e58ea38
332f3eb
7df58c7
e170273
e091bd6
f1ec7de
9365e3d
78af696
e70c241
5926df2
cb5bc5b
1800eff
c3668a6
892c704
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,11 +13,6 @@ on: | |
required: false | ||
default: true | ||
type: boolean | ||
changelog-config: | ||
description: "Changelog config path." | ||
required: false | ||
default: "" | ||
type: string | ||
working-directory: | ||
description: "Working directory containing `.bumpversion.cfg`. (Default is .)" | ||
required: false | ||
|
@@ -57,34 +52,35 @@ jobs: | |
uses: bakdata/ci-templates/actions/[email protected] | ||
with: | ||
ref: ${{ github.event.repository.default_branch }} | ||
persist-credentials: false # required for pushing to protected branch later | ||
persist-credentials: true # required for pushing to protected branch later | ||
|
||
- name: Bump version | ||
- name: Setup Git | ||
run: | | ||
git config --global user.name "${{ secrets.github-username }}" | ||
git config --global user.email "${{ secrets.github-email }}" | ||
|
||
- name: Remove snapshot suffix | ||
id: bump-version | ||
uses: bakdata/ci-templates/actions/bump-version@v1.21.2 | ||
uses: bakdata/ci-templates/actions/bump-version@feat/new-bumpversion | ||
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. TODO: prebump version |
||
with: | ||
release-type: ${{ inputs.release-type }} | ||
release-type: "release" | ||
working-directory: ${{ inputs.working-directory }} | ||
|
||
- name: Commit .bumpversion.cfg file without snapshot | ||
run: | | ||
git add .bumpversion.cfg | ||
git commit -m "Bump version ${{ steps.bump-version.outputs.old-version }} → ${{ steps.bump-version.outputs.release-version }}" | ||
git fetch origin | ||
git rebase --strategy-option=theirs origin/main | ||
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. Why is there a need for rebasing if we checked out right before? |
||
git push --verbose | ||
|
||
- name: Create changelog | ||
id: build-changelog | ||
uses: bakdata/ci-templates/actions/changelog-generate@1.35.0 | ||
uses: bakdata/ci-templates/actions/changelog-generate@tiedemann/changelog-action | ||
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. Did you test the case where we also want to have the up to date snapshot in a file on the default branch and the tag? |
||
if: ${{ inputs.changelog }} | ||
with: | ||
github-token: ${{ secrets.github-token }} | ||
config: ${{ inputs.changelog-config }} | ||
new-tag: ${{ steps.bump-version.outputs.release-version }} | ||
fetch-reviewers: "true" | ||
fetch-release-information: "true" | ||
|
||
- name: Commit and push changes including .bumpversion.cfg file | ||
uses: bakdata/ci-templates/actions/[email protected] | ||
with: | ||
ref: ${{ github.event.repository.default_branch }} | ||
commit-message: "Bump version ${{ steps.bump-version.outputs.old-version }} → ${{ steps.bump-version.outputs.release-version }}" | ||
github-username: ${{ secrets.github-username }} | ||
github-email: ${{ secrets.github-email }} | ||
github-token: ${{ secrets.github-token }} | ||
tag: ${{ steps.bump-version.outputs.release-version }} | ||
|
||
- name: Tag and release | ||
uses: bakdata/ci-templates/actions/[email protected] | ||
|
@@ -95,3 +91,18 @@ jobs: | |
github-token: ${{ secrets.github-token }} | ||
release-title: "${{ steps.bump-version.outputs.release-version }}" | ||
release-body: "${{ steps.build-changelog.outputs.single-changelog }}" | ||
|
||
- name: Bump to next snapshot version | ||
id: bump-version-snapshot | ||
uses: bakdata/ci-templates/actions/bump-version@feat/new-bumpversion | ||
with: | ||
release-type: ${{ inputs.release-type }} | ||
working-directory: ${{ inputs.working-directory }} | ||
|
||
- name: Commit .bumpversion.cfg file new version and snapshot | ||
run: | | ||
git add .bumpversion.cfg | ||
git commit -m "Bump version ${{ steps.bump-version.outputs.release-version }} → ${{ steps.bump-version-snapshot.outputs.release-version }}" | ||
git fetch origin | ||
git rebase --strategy-option=theirs origin/main | ||
git push --verbose |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,25 @@ | ||
name: "Bump version" | ||
description: "Bump version with python bump2version using .bumpversion.cfg" | ||
description: "Bump version with python bump-my-version using .bumpversion.cfg" | ||
# config example .bumpversion.cfg: | ||
# [bumpversion] | ||
# current_version = 1.0.0 | ||
# search = version: {current_version} | ||
# replace = version: {new_version} | ||
# parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(-(?P<release>snapshot))? | ||
# serialize = | ||
# {major}.{minor}.{patch}-{release} | ||
# {major}.{minor}.{patch} | ||
|
||
# [bumpversion:part:release] | ||
# first_value = snapshot | ||
# optional_value = release | ||
# values = | ||
# snapshot | ||
# release | ||
Comment on lines
+3
to
+18
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. Nice that there is a comment here, ideally you can also put this in the docs |
||
|
||
inputs: | ||
release-type: | ||
description: "The type of the release (major, minor or patch)." | ||
description: "The type of the release (release, major, minor or patch). Release is a special case, where the snapshot suffix is removed." | ||
required: true | ||
working-directory: | ||
description: "The directory containing the `.bumpversion.cfg` file." | ||
|
@@ -25,20 +41,27 @@ outputs: | |
runs: | ||
using: "composite" | ||
steps: | ||
- name: Set up bump2version | ||
- name: Set up bump-my-version | ||
run: | | ||
pipx install bump2version | ||
pipx install bump-my-version | ||
shell: bash | ||
|
||
- name: Bump version | ||
id: bump-version | ||
run: | | ||
parameters=(--no-commit --no-tag ${{ inputs.release-type }}) | ||
echo "old-version=$(python -c "from configparser import ConfigParser; cfg = ConfigParser(); cfg.read('.bumpversion.cfg'); print(cfg['bumpversion']['current_version'])")" >> "$GITHUB_OUTPUT" | ||
if [ -n "${{ inputs.new-version }}" ]; then | ||
yannick-roeder marked this conversation as resolved.
Show resolved
Hide resolved
|
||
parameters+=(--new-version ${{ inputs.new-version }}) | ||
echo "old-version=$(bump-my-version show current_version | tail -1)" >> "$GITHUB_OUTPUT" | ||
|
||
if [[ "${{ inputs.new-version }}" != "" ]]; then | ||
bump-my-version --new-version ${{ inputs.new-version }} | ||
else | ||
bump-my-version bump ${{ inputs.release-type }} | ||
fi | ||
bump2version "${parameters[@]}" | ||
echo "new-version=$(python -c "from configparser import ConfigParser; cfg = ConfigParser(); cfg.read('.bumpversion.cfg'); print(cfg['bumpversion']['current_version'])")" >> "$GITHUB_OUTPUT" | ||
echo "new-version=$(bump-my-version show current_version | tail -1)" >> "$GITHUB_OUTPUT" | ||
# release: a.b.c-snapshot -> a.b.c | ||
# release a.b.c -> crash | ||
# major: a.b.c(-snapshot)? -> a+1.0.0-snapshot | ||
# minor: a.b.c(-snapshot)? -> a.b+1.0-snapshot | ||
# patch: a.b.c(-snapshot)? -> a.b.c+1-snapshot | ||
# TLDR: release removes the snapshot suffix | ||
Comment on lines
+60
to
+65
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. Same as above, nice comments, but please also add it in the docs |
||
shell: bash | ||
working-directory: ${{ inputs.working-directory }} |
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.
Why did this change? I think this would lead to the CI being logged in with default credentials and not with the bot user