diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 9b297748029bc..90cc2fc1e669e 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -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 @@ -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: @@ -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