File tree 2 files changed +13
-4
lines changed
check_branch_and_release_type
2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change 25
25
FORCE_RELEASE=${{ inputs.force_release == 'yes' }}
26
26
FORCE_NOT_RELEASE=${{ inputs.force_release == 'no' }}
27
27
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') ) }}
29
29
if $FORCE_RELEASE; then
30
30
ISRELEASE=true
31
31
elif $FORCE_NOT_RELEASE; then
46
46
script : |
47
47
core.setFailed('Snapshot packages can not be created on the default branch. Release Type: ${{ inputs.release_type }}, Branch: ${{ github.ref_name }}')
48
48
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') }}
51
51
uses : actions/github-script@v7
52
52
with :
53
53
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 79
79
else
80
80
echo "new_version=$NBGV_SimpleVersion-SNAPSHOT" >> $GITHUB_OUTPUT
81
81
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
82
91
elif [[ "$BRANCH_NAME_TRUNC" != "" && "$BRANCH_NAME_TRUNC" != "master" && "$BRANCH_NAME_TRUNC" != "main" ]]; then
83
92
echo "new_version=$NBGV_SimpleVersion-$BRANCH_NAME_TRUNC" >> $GITHUB_OUTPUT
84
93
else
You can’t perform that action at this time.
0 commit comments