Skip to content

Create Release

Create Release #93

name: Create Release
on:
workflow_dispatch:
inputs:
versionName:
description: 'Semantic Version Number (i.e., 5.5.0 or patch, minor, major)'
required: true
default: patch
jobs:
create_release:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
with:
ref: main
ssh-key: ${{ secrets.CMU_DELPHI_DEPLOY_MACHINE_SSH }}
- name: Reset dev branch
run: |
git fetch origin dev:dev
git reset --hard origin/dev
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
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
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 }}
commit-message: 'chore: release delphi-epidata ${{ steps.version.outputs.next_tag }}'
base: main
title: Release Delphi Epidata ${{ steps.version.outputs.next_tag }}
labels: chore
reviewers: melange396
assignees: melange396
body: |
Releasing Delphi Epidata ${{ steps.version.outputs.next_tag }}.