Skip to content

Commit e0e0840

Browse files
authored
ci: Properly support consecutive pre releases (#274)
Consecutive pre-releases are not currently possible. Running two release pipelines with the same pre release flavor would result in the following releases: 1.0.1-rc.0 and 1.0.2-rc.0. But what we want when we run the second pre-release pipeline is 1.0.1-rc.1. Now, parse the latest release name and if the latest is a pre-release and its flavor matches the inputted flavor, we only increment the pre-release version as opposed to a full version bump. [DEVX-3004]
1 parent 3e4a135 commit e0e0840

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

.github/workflows/release.yml

+16-2
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,31 @@ jobs:
6464
if: ${{ steps.prep.outputs.tag_name == '' }}
6565
env:
6666
GITHUB_TOKEN: ${{ github.token }}
67+
GH_TOKEN: ${{ github.token }}
6768
run: |
6869
if [ -z "${{ github.event.inputs.releaseType }}" ] && [ -z "${{ github.event.inputs.preReleaseFlavor }}" ];then
6970
echo "No release type provided."
7071
exit 1
7172
fi
7273
74+
RELEASE_TYPE="${{ github.event.inputs.releaseType }}"
75+
7376
if [ -n "${{ github.event.inputs.preReleaseFlavor }}" ];then
74-
PRE_RELEASE_ARGS="--preRelease=${{ github.event.inputs.preReleaseFlavor }} --github.preRelease"
77+
LATEST_TAG=$(gh release list --limit 1 --json tagName --jq '.[] | .tagName')
78+
# NOTE: Expected tag format is {VERSION}-{FLAVOR}.{FLAVOR_VERSION}
79+
LATEST_FLAVOR=$(echo ${LATEST_TAG} | awk -F'-' '{ print $2 }' | awk -F'.' '{ print $1 }')
80+
81+
if [ "${LATEST_FLAVOR}" == "${{ github.event.inputs.preReleaseFlavor}}" ];then
82+
# NOTE: If the inputted pre-release flavor matches the current pre-release flavor, we only
83+
# want to increment the pre-release version instead of a full version bump.
84+
PRE_RELEASE_ARGS="--preRelease"
85+
RELEASE_TYPE=""
86+
else
87+
PRE_RELEASE_ARGS="--preRelease=${{ github.event.inputs.preReleaseFlavor }} --github.preRelease"
88+
fi
7589
fi
7690
77-
npx release-it ${{ github.event.inputs.releaseType }} ${PRE_RELEASE_ARGS}
91+
npx release-it ${RELEASE_TYPE} ${PRE_RELEASE_ARGS}
7892
7993
release-windows-bundle:
8094
runs-on: windows-latest

0 commit comments

Comments
 (0)