File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed
check_branch_and_release_type Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change 2525 FORCE_RELEASE=${{ inputs.force_release == 'yes' }}
2626 FORCE_NOT_RELEASE=${{ inputs.force_release == 'no' }}
2727 CHECK_BRANCH_FOR_RELEASE=${{ inputs.force_release == 'branch' }}
28- BRANCH_ALLOWS_RELEASE=${{ (inputs.release_type == 'Major' || inputs.release_type == 'Minor' || inputs.release_type == 'Patch') && (github.event.repository.default_branch == github.ref_name) }}
28+ BRANCH_ALLOWS_RELEASE=${{ (inputs.release_type == 'Major' || inputs.release_type == 'Minor' || inputs.release_type == 'Patch') && (github.event.repository.default_branch == github.ref_name || startsWith(github.ref_name, 'release') ) }}
2929 if $FORCE_RELEASE; then
3030 ISRELEASE=true
3131 elif $FORCE_NOT_RELEASE; then
4646 script : |
4747 core.setFailed('Snapshot packages can not be created on the default branch. Release Type: ${{ inputs.release_type }}, Branch: ${{ github.ref_name }}')
4848
49- - name : Fail if Release and not on Default branch
50- if : ${{ inputs.release_type != 'Snapshot' && github.event.repository.default_branch != github.ref_name }}
49+ - name : Fail if Release and not on Default branch or release-yyyy-q branch
50+ if : ${{ inputs.release_type != 'Snapshot' && github.event.repository.default_branch != github.ref_name && !startsWith(github.ref_name, 'release') }}
5151 uses : actions/github-script@v7
5252 with :
5353 script : |
54- core.setFailed('Releases can not be created on a feature branch. Release Type: ${{ inputs.release_type }}, Branch: ${{ github.ref_name }}')
54+ core.setFailed('Releases can only be created on a Default or release-yyyy-q branch. Release Type: ${{ inputs.release_type }}, Branch: ${{ github.ref_name }}')
Original file line number Diff line number Diff line change 7979 else
8080 echo "new_version=$NBGV_SimpleVersion-SNAPSHOT" >> $GITHUB_OUTPUT
8181 fi
82+ elif [[ "$BRANCH_NAME" =~ ^release.* ]]; then
83+ git fetch --tags --all
84+ # Find the base tag that the branch derived from
85+ BASE_TAG=$(git describe --tags --abbrev=0 $(git merge-base HEAD origin/main))
86+ BASE_TAG_CLEAN=$(echo "$BASE_TAG" | sed -E 's/-r[0-9]+$//')
87+ # Count number of commits since the clean tag
88+ REV_COUNT=$(git rev-list --count ${BASE_TAG_CLEAN}..HEAD)
89+ VERSION="$(echo "$BASE_TAG_CLEAN" | sed -E 's/^v//')-r${REV_COUNT}"
90+ echo "new_version=$VERSION" >> $GITHUB_OUTPUT
8291 elif [[ "$BRANCH_NAME_TRUNC" != "" && "$BRANCH_NAME_TRUNC" != "master" && "$BRANCH_NAME_TRUNC" != "main" ]]; then
8392 echo "new_version=$NBGV_SimpleVersion-$BRANCH_NAME_TRUNC" >> $GITHUB_OUTPUT
8493 else
You can’t perform that action at this time.
0 commit comments