Skip to content

fix(pyclient ci): validate version arg in create-release #1473

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

Merged
merged 2 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
23 changes: 18 additions & 5 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:
inputs:
versionName:
description: 'Semantic Version Number (i.e., 5.5.0 or patch, minor, major, prepatch, preminor, premajor, prerelease)'
description: 'Semantic Version Number (i.e., 5.5.0 or patch, minor, major)'
required: true
default: patch

Expand All @@ -27,10 +27,23 @@ jobs:
python-version: 3.8
- name: Change version number
id: version
# See this issue for explanation and testing:
# https://github.com/cmu-delphi/delphi-epidata/pull/1473
run: |
python -m pip install bump2version
echo -n "::set-output name=next_tag::"
bump2version --list ${{ github.event.inputs.versionName }} | grep new_version | sed -r s,"^.*=",,
python -m pip install bump-my-version
echo -n "next_tag=" >> $GITHUB_OUTPUT
allowed_pattern="^(major|minor|patch|[0-9]+\.[0-9]+\.[0-9]+)$"

if [[ ! ${{ github.event.inputs.versionName }} =~ $allowed_pattern ]]; then
echo "\nInvalid version name: ${{ github.event.inputs.versionName }}"
exit 1
fi

if [[ ${{ github.event.inputs.versionName }} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "${{ github.event.inputs.versionName }}"
else
echo $(bump-my-version show-bump | grep ${{ github.event.inputs.versionName }} | sed -r s,"^.*─ ",,)
fi
- name: Get main branch SHA
id: base-sha
run: echo "sha=$(git rev-parse origin/main)" >> $GITHUB_OUTPUT
Expand All @@ -46,7 +59,7 @@ jobs:
if: steps.changed-py.outputs.any_changed == 'true'
run: |
cd src/client/packaging/pypi
bump2version --allow-dirty --new-version ${{ steps.version.outputs.next_tag }} ignore_part
bump-my-version --allow-dirty --new-version ${{ steps.version.outputs.next_tag }}
- name: Create pull request into prod
uses: peter-evans/create-pull-request@v3
with:
Expand Down
1 change: 0 additions & 1 deletion requirements.dev.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
aiohttp==3.9.4
black>=20.8b1
bump2version==1.0.1
covidcast==0.1.5
delphi_utils
docker==6.0.1
Expand Down
8 changes: 0 additions & 8 deletions src/client/packaging/pypi/.bumpversion.cfg

This file was deleted.

24 changes: 24 additions & 0 deletions src/client/packaging/pypi/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,27 @@ dependencies = ["aiohttp", "delphi-utils", "requests>=2.7.0", "tenacity"]
[project.urls]
"Homepage" = "https://github.com/cmu-delphi/delphi-epidata"
"Changelog" = "https://github.com/cmu-delphi/delphi-epidata/blob/main/src/client/packaging/pypi/CHANGELOG.md"

[tool.bumpversion]
current_version = "4.1.23"
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
serialize = ["{major}.{minor}.{patch}"]
search = "{current_version}"
replace = "{new_version}"
regex = false
ignore_missing_version = false
ignore_missing_files = false
tag = false
sign_tags = false
tag_name = "v{new_version}"
tag_message = "Bump version: {current_version} → {new_version}"
allow_dirty = false
commit = false
message = "Bump version: {current_version} → {new_version}"
commit_args = ""

[[tool.bumpversion.files]]
filename = "../../delphi_epidata.py"

[[tool.bumpversion.files]]
filename = "pyproject.toml"
Loading