Skip to content
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

Open
wants to merge 32 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
0375c17
commit-message
yordanovsstoyan Aug 29, 2023
a0416c6
commit-message
yordanovsstoyan Aug 29, 2023
82db094
commit-message
yordanovsstoyan Aug 29, 2023
99c4971
commit-message
yordanovsstoyan Aug 31, 2023
78b45d4
reboot
yordanovsstoyan Oct 3, 2023
54c86f7
test
yordanovsstoyan Oct 3, 2023
d0d3c60
test
yordanovsstoyan Oct 3, 2023
0b030f3
test
yordanovsstoyan Oct 4, 2023
7a76951
remove-variable
yordanovsstoyan Oct 4, 2023
2c7f4c0
changes
yordanovsstoyan Nov 9, 2023
a2a3e0c
fix: remove redundant action
DerTiedemann Aug 6, 2024
5eea497
fix:
DerTiedemann Aug 6, 2024
43f8923
lint: fix actionlint complaints
DerTiedemann Aug 6, 2024
fbfe193
fix: add missing inline bash operator
DerTiedemann Aug 8, 2024
c12b090
chore: prep new version for release
DerTiedemann Sep 2, 2024
eda6cff
Revert "chore: prep new version for release"
DerTiedemann Sep 2, 2024
e592eec
fix: make sure there is an empty string for the comparison
DerTiedemann Sep 3, 2024
f1bc6f0
fix: remove deprecated flags
DerTiedemann Sep 3, 2024
e58ea38
fix: only use bump
DerTiedemann Sep 3, 2024
332f3eb
fix: proper outpuit
DerTiedemann Sep 3, 2024
7df58c7
fix: new chamgelog action
DerTiedemann Sep 3, 2024
e170273
fix: use different commit message for second commit
DerTiedemann Sep 3, 2024
e091bd6
test
DerTiedemann Sep 3, 2024
f1ec7de
fix: try single push
DerTiedemann Sep 3, 2024
9365e3d
fix: add git username + email
DerTiedemann Sep 3, 2024
78af696
fix: try with push
DerTiedemann Sep 3, 2024
e70c241
fix: add pull command
DerTiedemann Sep 3, 2024
5926df2
fix: add git config
DerTiedemann Sep 3, 2024
cb5bc5b
fix: try to use checkout to pull the latest changes
DerTiedemann Sep 3, 2024
1800eff
fix: try using normal git commits
DerTiedemann Sep 3, 2024
c3668a6
fix: persist credentials
DerTiedemann Sep 3, 2024
892c704
fix: make commit message correct
DerTiedemann Sep 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 34 additions & 23 deletions .github/workflows/bump-version-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Copy link
Member

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


- 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
Copy link
Member

Choose a reason for hiding this comment

The 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
Copy link
Member

Choose a reason for hiding this comment

The 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
Copy link
Member

Choose a reason for hiding this comment

The 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]
Expand All @@ -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
43 changes: 33 additions & 10 deletions actions/bump-version/action.yaml
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
Copy link
Member

Choose a reason for hiding this comment

The 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."
Expand All @@ -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
Copy link
Member

Choose a reason for hiding this comment

The 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 }}
10 changes: 5 additions & 5 deletions docs/actions/bump-version/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ steps:

<!-- AUTO-DOC-INPUT:START - Do not remove or modify this section -->

| INPUT | TYPE | REQUIRED | DEFAULT | DESCRIPTION |
| ----------------- | ------ | -------- | ------- | ----------------------------------------------------- |
| new-version | string | false | | |
| release-type | string | true | | The type of the release (major, minor or patch). |
| working-directory | string | false | `"."` | The directory containing the `.bumpversion.cfg` file. |
| INPUT | TYPE | REQUIRED | DEFAULT | DESCRIPTION |
| ----------------- | ------ | -------- | ------- | -------------------------------------------------------------------------------------------------------------------------- |
| new-version | string | false | | |
| release-type | string | true | | The type of the release (release, major, minor or patch). Release is a special case, where the snapshot suffix is removed. |
| working-directory | string | false | `"."` | The directory containing the `.bumpversion.cfg` file. |

<!-- AUTO-DOC-INPUT:END -->

Expand Down
1 change: 0 additions & 1 deletion docs/workflows/bump-version-release/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ jobs:
| INPUT | TYPE | REQUIRED | DEFAULT | DESCRIPTION |
| ----------------- | ------- | -------- | ------- | --------------------------------------------------------------- |
| changelog | boolean | false | `true` | Create changelog for release. |
| changelog-config | string | false | | Changelog config path. |
| release-type | string | true | | Scope of the release (major, minor or patch). |
| working-directory | string | false | `"."` | Working directory containing `.bumpversion.cfg`. (Default is .) |

Expand Down
Loading