Release #60
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
name: Release | |
on: | |
workflow_dispatch: | |
inputs: | |
releaseType: | |
description: "Release type - major, minor or patch" | |
required: true | |
default: "patch" | |
preReleaseFlavor: | |
description: "Pre-Release flavor - rc, beta, or anything" | |
required: false | |
default: "" | |
env: | |
NPM_TOKEN: ${{secrets.NPM_TOKEN}} | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: ".nvmrc" | |
cache: "npm" | |
- name: Setup Git | |
run: | | |
git config --global user.name "devx-sauce-bot" | |
git config --global user.email "[email protected]" | |
- name: Install Dependencies | |
run: npm ci | |
env: | |
HUSKY: 0 | |
- name: Build | |
run: npm run build | |
- name: Login to NPM | |
run: npm set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} | |
- name: Generate (Pre-)Release Draft | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_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 | |
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} |