Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
Signed-off-by: Oliver Koenig <[email protected]>
  • Loading branch information
ko3n1g committed Jul 10, 2024
1 parent 3faaa67 commit 185bd10
Showing 1 changed file with 31 additions and 28 deletions.
59 changes: 31 additions & 28 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,14 @@ on:
- major
- minor
- patch
- prerelease_only
is_prerelease:
description: 'Is release candidate'
- pre-release
create_rc:
description: 'Create release-candidate'
required: false
default: false
type: boolean
release_rc:
description: 'Release release-candidate'
required: false
default: false
type: boolean
Expand All @@ -22,6 +27,13 @@ jobs:
main:
runs-on: ubuntu-latest
steps:
- name: Validate inputs
run: |
if [[ ${{ inputs.create_rc }} == true && ${{ inputs.release_rc }} ]]; then
echo "Trying to create and finalize a release candidate at the same time is difficult."
exit 1
fi
- name: Checkout repository
uses: actions/checkout@v4
with:
Expand All @@ -37,34 +49,25 @@ jobs:
MAJOR=$(sed -n 's/^MAJOR\s*=\s*\([0-9]\+\)/\1/p' $VERSION_FILE)
MINOR=$(sed -n 's/^MINOR\s*=\s*\([0-9]\+\)/\1/p' $VERSION_FILE)
PATCH=$(sed -n 's/^PATCH\s*=\s*\([0-9]\+\)/\1/p' $VERSION_FILE)
PRE_RELEASE=$(sed -n "s/^PRE_RELEASE\s*=\s*'\([^']\+\)'/\1/p" $VERSION_FILE)
echo Version bump: ${{ inputs.version_bump }}
# If version_bump == null and not is_prerelease
# If version_bump == null and is_prerelease and not has_prerelease
# error
# If version_bump and not is_prerelease and has_prerelease
#
if [[ ${{ inputs.version_bump }} == "major" && -z $PRE_RELEASE ]]; then
MAJOR=$((MAJOR + 1))
elif [[ ${{ inputs.version_bump }} == "minor" && -z $PRE_RELEASE ]]; then
MINOR=$((MINOR + 1))
elif [[ ${{ inputs.version_bump }} == "patch" && -z $PRE_RELEASE ]]; then
PATCH=$((PATCH + 1))
elif [[ ${{ inputs.version_bump }} == "pre-release" ]]; then
if [[ -z $pre_release ]]; then
new_version="$major.$minor.$patch-rc1"
else
pre_number=$(echo $pre_release | grep -o '[0-9]*$')
pre_number=$((pre_number + 1))
new_version="$major.$minor.$patch-rc$pre_number"
fi
else
echo "Invalid bump type."
PRE_RELEASE=$(sed -n "s/^PRE_RELEASE\s*=\s*'\([^']\+\)'/\1/p" $VERSION_FILE)
# if has_prerelease AND create_rc -> error
if [[ -n $PRE_RELEASE && ${{ inputs.create_rc }} == true ]]; then
echo NeMo Toolkit already has a RC.
exit 1
fi
# if not has_prerelease AND release_rc -> error
if [[ -z $PRE_RELEASE && ${{ inputs.release_rc }} == true ]]; then
echo NeMo Toolkit does not have a RC to release
exit 1
fi
# if not has_prerelease AND pre-release -> error
if [[ -z $PRE_RELEASE && ${{ inputs.version_bump }} == "pre-release" ]]l; then
echo NeMo Toolkit does not have a RC to bump
fi
if [[ "${{ inputs.version_bump }}" == "major" ]]; then
MAJOR=$(( $MAJOR + 1 ))
MINOR=0
Expand Down

0 comments on commit 185bd10

Please sign in to comment.