Skip to content

Decouple client release from Delphi release #1465

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 9 commits into from
Jun 25, 2024
4 changes: 0 additions & 4 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ tag = False

[bumpversion:file:src/client/delphi_epidata.R]

[bumpversion:file:src/client/delphi_epidata.py]

[bumpversion:file:src/client/packaging/npm/package.json]

[bumpversion:file:src/client/packaging/pypi/pyproject.toml]

[bumpversion:file:dev/local/setup.cfg]
40 changes: 36 additions & 4 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,11 +27,43 @@ 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,"^.*=",,
- name: Create pull request into prod
if [[ ${{ github.event.inputs.versionName }} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
# use given version number
NEXT_TAG="${{ github.event.inputs.versionName }}"
elif [[ ${{ github.event.inputs.versionName }} =~ ^(major|minor|patch)$ ]]; then
# calculate new version number based on given tag
NEXT_TAG=$(bump2version --dry-run --list ${{ github.event.inputs.versionName }} | grep ^new_version | sed -r s,"^.*=",,)
else
echo "\nInvalid version name: ${{ github.event.inputs.versionName }}"
exit 1
fi
# apply given or calculated version number
bump2version --new-version $NEXT_TAG _ignored_arg_
# save version number for later
echo "next_tag=$NEXT_TAG" >> $GITHUB_OUTPUT
- name: Get Python client file changes
id: changed-py
uses: dorny/paths-filter@v3
with:
base: "main"
ref: "dev"
filters: |
python_client_changed:
- src/client/delphi_epidata.py
- src/client/packaging/pypi/**
- name: Bump Python versions if client files changed
if: steps.changed-py.outputs.python_client_changed == 'true'
# _ignored_arg_ below is required because of tool quirk
# https://github.com/c4urself/bump2version/issues/22
run: |
cd src/client/packaging/pypi
# this is using the new literal version number (steps.version.outputs.next_tag) output from the bump2version step above, not the workflow input (github.event.inputs.versionName) which can be relative
bump2version --allow-dirty --new-version ${{ steps.version.outputs.next_tag }} _ignored_arg_
- name: Create pull request into main
uses: peter-evans/create-pull-request@v3
with:
branch: release/delphi-epidata-${{ steps.version.outputs.next_tag }}
Expand Down
32 changes: 28 additions & 4 deletions .github/workflows/release-helper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,29 @@ jobs:
if: github.repository_owner != 'cmu-delphi'
run: exit 1

client_changed:
needs: correct_repository
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Get Python client file changes
id: changed-py
uses: dorny/paths-filter@v3
with:
# when base and ref are the same, changes are detected against the most recent commit before the push.
# see https://github.com/dorny/paths-filter#usage for details.
base: 'main'
ref: 'main'
filters: |
python_client_changed:
- src/client/delphi_epidata.py
- src/client/packaging/pypi/**
outputs:
python_client_changed: ${{ steps.changed-py.outputs.python_client_changed }}

create_release:
needs: correct_repository
runs-on: ubuntu-latest
Expand All @@ -29,8 +52,8 @@ jobs:
id: extract_version
run: |
python -m pip install bump2version
echo -n "::set-output name=version::"
bump2version --dry-run --list patch | grep ^current_version | sed -r s,"^.*=",,
VERSION=$(bump2version --dry-run --list patch | grep ^current_version | sed -r s,"^.*=",,)
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Create Release
id: create_release
uses: release-drafter/release-drafter@v5
Expand All @@ -45,7 +68,8 @@ jobs:
tag_name: ${{ steps.create_release.outputs.tag_name }}

release_python_client:
needs: create_release
needs: [client_changed, create_release]
if: needs.client_changed.outputs.python_client_changed == 'true'
runs-on: ubuntu-latest
steps:
- name: Check out code
Expand Down Expand Up @@ -95,7 +119,7 @@ jobs:
uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16.x'
node-version: "16.x"
- name: Cache Node.js modules
uses: actions/cache@v2
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: 8 additions & 0 deletions src/client/packaging/pypi/.bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[bumpversion]
current_version = 4.1.23
commit = False
tag = False

[bumpversion:file:../../delphi_epidata.py]

[bumpversion:file:pyproject.toml]
Loading