Create development branch #23
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Create development branch | |
on: | |
workflow_dispatch: | |
inputs: | |
release_type: | |
type: choice | |
description: "Release type" | |
options: | |
- major | |
- minor | |
- patch | |
default: patch | |
permissions: | |
contents: write | |
jobs: | |
create_branch: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
token: ${{ secrets.GH_TOKEN }} | |
- name: Check branch [Allowed only from main] | |
run: | | |
current_branch=$(git branch --show-current) | |
if [[ "$current_branch" != "main" ]]; then | |
echo "Workflow can only be run from the main branch" | |
exit 1 | |
fi | |
- name: Set up Python and Upgrade pip | |
uses: ./.github/actions/setup_python | |
with: | |
python-version: "3.11" | |
- name: Update development version | |
uses: ./.github/actions/bump_version | |
with: | |
type: ${{ inputs.release_type }} | |
commit: false | |
tag: false | |
push: false | |
- name: Create new development branch | |
run: | | |
NEW_VERSION=$(cat soupsavvy/VERSION) | |
# remove pre-release suffix if exists | |
NEW_VERSION=$(echo $NEW_VERSION | cut -d'-' -f1) | |
DEV_BRANCH_NAME="dev/${NEW_VERSION}" | |
# remove uncommitted changes | |
git reset --hard | |
if [ -n "$(git branch --list $DEV_BRANCH_NAME)" ] | |
then | |
echo "Development branch for this version with name $DEV_BRANCH_NAME already exists." | |
exit 1 | |
fi | |
echo "Creating new development branch: $DEV_BRANCH_NAME" | |
git checkout -b $DEV_BRANCH_NAME | |
- name: Update development version with commit and tag | |
uses: ./.github/actions/bump_version | |
with: | |
type: ${{ inputs.release_type }} | |
commit: true | |
tag: true | |
push: true |