Skip to content

Commit

Permalink
ci: Properly support consecutive pre releases (#77)
Browse files Browse the repository at this point in the history
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]
  • Loading branch information
mhan83 authored Sep 5, 2024
1 parent d94bfd5 commit f169340
Showing 1 changed file with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,32 @@ jobs:
- name: Login to NPM
run: npm set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}

- name: Pre-Release
if: ${{ github.event.inputs.preReleaseFlavor != '' }}
run: npm run release:ci -- ${{ github.event.inputs.releaseType }} --preRelease=${{ github.event.inputs.preReleaseFlavor }}
- name: Generate (Pre-)Release Draft
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ github.token }}
GH_TOKEN: ${{ github.token }}
run: |
if [ -z "${{ github.event.inputs.releaseType }}" ] && [ -z "${{ github.event.inputs.preReleaseFlavor }}" ];then
echo "No release type provided."
exit 1
fi
- name: Release
if: ${{ github.event.inputs.preReleaseFlavor == '' }}
run: npm run release:ci -- ${{ github.event.inputs.releaseType }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TYPE="${{ github.event.inputs.releaseType }}"
if [ -n "${{ github.event.inputs.preReleaseFlavor }}" ];then
LATEST_TAG=$(gh release list --limit 1 --json tagName --jq '.[] | .tagName')
# NOTE: Expected tag format is {VERSION}-{FLAVOR}.{FLAVOR_VERSION}
LATEST_FLAVOR=$(echo ${LATEST_TAG} | awk -F'-' '{ print $2 }' | awk -F'.' '{ print $1 }')
if [ "${LATEST_FLAVOR}" == "${{ github.event.inputs.preReleaseFlavor}}" ];then
# NOTE: If the inputted pre-release flavor matches the current pre-release flavor, we only
# want to increment the pre-release version instead of a full version bump.
PRE_RELEASE_ARGS="--preRelease"
RELEASE_TYPE=""
else
PRE_RELEASE_ARGS="--preRelease=${{ github.event.inputs.preReleaseFlavor }} --github.preRelease"
fi
fi
npm run release:ci -- ${RELEASE_TYPE} ${PRE_RELEASE_ARGS}

0 comments on commit f169340

Please sign in to comment.