generated from saucelabs/new-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: improve pre-release workflow (#18)
- Loading branch information
1 parent
db5e16e
commit 5e70ac8
Showing
1 changed file
with
28 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ on: | |
required: true | ||
default: 'patch' | ||
preReleaseFlavor: | ||
description: 'Pre-Release flavor - rc, beta, or anything. Pre-Releases are always patch releases.' | ||
description: 'Pre-Release flavor - rc, beta, or anything' | ||
required: false | ||
default: '' | ||
|
||
|
@@ -37,18 +37,34 @@ jobs: | |
git config --global user.email "[email protected]" | ||
- name: Setup NPM | ||
run: npm set "//registry.npmjs.org/:_authToken" ${{ secrets.NPM_TOKEN }} | ||
run: npm set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} | ||
|
||
- name: Pre-Release | ||
if: ${{ github.event.inputs.preReleaseFlavor != '' }} | ||
run: npm run release:ci -- --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} |