Skip to content

Commit 9d3a9ca

Browse files
dshemetovmelange396
andcommitted
fix(ci): use bump2version and validate
* add comments * revert bumpversion configs Co-authored-by: george <[email protected]>
1 parent 1f50b0b commit 9d3a9ca

File tree

4 files changed

+26
-35
lines changed

4 files changed

+26
-35
lines changed

.github/workflows/create-release.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ jobs:
3030
# See this issue for explanation and testing:
3131
# https://github.com/cmu-delphi/delphi-epidata/pull/1473
3232
run: |
33-
python -m pip install bump-my-version
34-
echo -n "next_tag=" >> $GITHUB_OUTPUT
33+
python -m pip install bump2version
3534
allowed_pattern="^(major|minor|patch|[0-9]+\.[0-9]+\.[0-9]+)$"
3635
3736
if [[ ! ${{ github.event.inputs.versionName }} =~ $allowed_pattern ]]; then
@@ -40,10 +39,16 @@ jobs:
4039
fi
4140
4241
if [[ ${{ github.event.inputs.versionName }} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
43-
echo "${{ github.event.inputs.versionName }}"
42+
# use given version number
43+
NEXT_TAG="${{ github.event.inputs.versionName }}"
4444
else
45-
echo $(bump-my-version show-bump | grep ${{ github.event.inputs.versionName }} | sed -r s,"^.*─ ",,)
45+
# calculate new version number based on given tag
46+
NEXT_TAG=$(bump2version --dry-run --list ${{ github.event.inputs.versionName }} | grep ^new_version | sed -r s,"^.*=",,)
4647
fi
48+
# apply given or calculated version number
49+
bump2version --new-version $NEXT_TAG _ignored_arg_
50+
# save version number for later
51+
echo "next_tag=$NEXT_TAG" >> $GITHUB_OUTPUT
4752
- name: Get main branch SHA
4853
id: base-sha
4954
run: echo "sha=$(git rev-parse origin/main)" >> $GITHUB_OUTPUT
@@ -57,9 +62,11 @@ jobs:
5762
src/client/packaging/pypi/**
5863
- name: Bump Python versions if client files changed
5964
if: steps.changed-py.outputs.any_changed == 'true'
65+
# _ignored_arg_ below is required because of tool quirk
66+
# https://github.com/c4urself/bump2version/issues/22
6067
run: |
6168
cd src/client/packaging/pypi
62-
bump-my-version --allow-dirty --new-version ${{ steps.version.outputs.next_tag }}
69+
bump2version --allow-dirty --new-version ${{ steps.version.outputs.next_tag }} _ignored_arg_
6370
- name: Create pull request into prod
6471
uses: peter-evans/create-pull-request@v3
6572
with:

.github/workflows/release-helper.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ jobs:
2525
id: changed-py
2626
uses: tj-actions/changed-files@v44
2727
with:
28-
files: |
29-
src/client/delphi_epidata.py
30-
src/client/packaging/pypi/**
28+
files: |
29+
src/client/delphi_epidata.py
30+
src/client/packaging/pypi/**
3131
outputs:
3232
any_changed: ${{ steps.changed-py.outputs.any_changed }}
3333

@@ -47,8 +47,8 @@ jobs:
4747
id: extract_version
4848
run: |
4949
python -m pip install bump2version
50-
echo -n "::set-output name=version::"
51-
bump2version --dry-run --list patch | grep ^current_version | sed -r s,"^.*=",,
50+
VERSION=$(bump2version --dry-run --list patch | grep ^current_version | sed -r s,"^.*=",,)
51+
echo "version=$VERSION" >> $GITHUB_OUTPUT
5252
- name: Create Release
5353
id: create_release
5454
uses: release-drafter/release-drafter@v5
@@ -114,7 +114,7 @@ jobs:
114114
uses: actions/checkout@v2
115115
- uses: actions/setup-node@v2
116116
with:
117-
node-version: '16.x'
117+
node-version: "16.x"
118118
- name: Cache Node.js modules
119119
uses: actions/cache@v2
120120
with:
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[bumpversion]
2+
current_version = 4.1.23
3+
commit = False
4+
tag = False
5+
6+
[bumpversion:file:../../delphi_epidata.py]
7+
8+
[bumpversion:file:pyproject.toml]

src/client/packaging/pypi/pyproject.toml

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -42,27 +42,3 @@ dependencies = ["aiohttp", "delphi-utils", "requests>=2.7.0", "tenacity"]
4242
[project.urls]
4343
"Homepage" = "https://github.com/cmu-delphi/delphi-epidata"
4444
"Changelog" = "https://github.com/cmu-delphi/delphi-epidata/blob/main/src/client/packaging/pypi/CHANGELOG.md"
45-
46-
[tool.bumpversion]
47-
current_version = "4.1.23"
48-
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
49-
serialize = ["{major}.{minor}.{patch}"]
50-
search = "{current_version}"
51-
replace = "{new_version}"
52-
regex = false
53-
ignore_missing_version = false
54-
ignore_missing_files = false
55-
tag = false
56-
sign_tags = false
57-
tag_name = "v{new_version}"
58-
tag_message = "Bump version: {current_version} → {new_version}"
59-
allow_dirty = false
60-
commit = false
61-
message = "Bump version: {current_version} → {new_version}"
62-
commit_args = ""
63-
64-
[[tool.bumpversion.files]]
65-
filename = "../../delphi_epidata.py"
66-
67-
[[tool.bumpversion.files]]
68-
filename = "pyproject.toml"

0 commit comments

Comments
 (0)