Skip to content

Commit 8ae4849

Browse files
committed
Change branch creation behaviour for pre-releases
1 parent cc17ed9 commit 8ae4849

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

.github/workflows/release.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,17 @@ jobs:
4545
# 5.2.0 => 5.2.1; 5.2.0-beta0 => 5.2.0
4646
# RELEASE_BRANCH: The name of the stable branch for this release series
4747
# Example: 5.2.0 => 5.2.x
48+
# Example: 5.2.0-beta1 => <current branch>
4849
run: |
4950
echo RELEASE_VERSION=${{ inputs.version }} >> $GITHUB_ENV
5051
echo RELEASE_VERSION_WITHOUT_SUFFIX=$(echo ${{ inputs.version }} | awk -F- '{print $1}') >> $GITHUB_ENV
5152
if [[ "${{ inputs.version }}" =~ (alpha|beta|rc)[0-9]+$ ]]; then
5253
echo NEXT_VERSION=$(echo ${{ inputs.version }} | awk -F- '{print $1}') >> $GITHUB_ENV
54+
echo RELEASE_BRANCH=${{ github.ref_name }} >> $GITHUB_ENV
5355
else
5456
echo NEXT_VERSION=$(echo ${{ inputs.version }} | awk -F. -v OFS=. '{$NF += 1 ; print}') >> $GITHUB_ENV
57+
echo RELEASE_BRANCH=$(echo ${{ inputs.version }} | awk -F. -v OFS=. '{$NF = "x" ; print}') >> $GITHUB_ENV
5558
fi
56-
echo RELEASE_BRANCH=$(echo ${{ inputs.version }} | awk -F. -v OFS=. '{$NF = "x" ; print}') >> $GITHUB_ENV
5759
5860
- name: "Ensure current snapshot version matches release version"
5961
run: |
@@ -90,11 +92,19 @@ jobs:
9092
9193
# If a non-patch release is created from a branch other than its
9294
# maintenance branch, create that branch from the current one and push it
95+
# Pre-releases don't have this behaviour, so we can check the full release
96+
# version including stability suffixes to exclude those
9397
- name: "Create new release branch for non-patch release"
94-
if: ${{ endsWith(env.RELEASE_VERSION_WITHOUT_SUFFIX, '.0') && env.RELEASE_BRANCH != github.ref_name }}
98+
if: ${{ endsWith(env.RELEASE_VERSION, '.0') && env.RELEASE_BRANCH != github.ref_name }}
9599
run: |
96100
echo '🆕 Creating new release branch ${{ env.RELEASE_BRANCH }} from ${{ github.ref_name }}' >> $GITHUB_STEP_SUMMARY
97-
git checkout -b ${RELEASE_BRANCH}
101+
git checkout -b ${{ env.RELEASE_BRANCH }}
102+
NEXT_MINOR_VERSION=$(echo "${{ env.RELEASE_VERSION }}" | awk -F. -v OFS=. '{$2 += 1 ; $NF = 0 ; print}'
103+
echo '➡️ Bumping version for ${{ github.ref_name }} branch to ${NEXT_MINOR_VERSION}' >> $GITHUB_STEP_SUMMARY
104+
git checkout ${{ github.ref_name }}
105+
.github/workflows/bump-version.sh "${{ env.RELEASE_VERSION_WITHOUT_SUFFIX }}-SNAPSHOT" "${NEXT_MINOR_VERSION}-SNAPSHOT"
106+
git push origin ${{ github.ref_name }}
107+
git checkout ${{ env.RELEASE_BRANCH }}
98108
99109
- name: "Set git author information"
100110
run: |

0 commit comments

Comments
 (0)