Release SDK to NPM #12
Workflow file for this run
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 SDK to NPM | |
on: | |
workflow_dispatch: | |
inputs: | |
channel: | |
type: choice | |
description: 'Choose the release channel/tag' | |
options: | |
- beta | |
- production | |
default: 'beta' | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
- name: Install pnpm | |
run: npm install -g pnpm | |
- name: Release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
run: | | |
curr_version="$(pnpm pkg get version --workspace='@expediagroup/lodging-connectivity-sdk' | sed -n 's/.*"\(.*\)".*/\1/p')" | |
echo "Current version: $curr_version" | |
if [ "${{ inputs.channel }}" == "production" ]; then | |
echo "Publishing a production release: $curr_version" | |
npm i | |
npx tsc | |
npm publish | |
elif [ "${{ inputs.channel }}" == "beta" ]; then | |
suffix_pattern="-beta.[0-9]+" | |
if [[ ! "$curr_version" =~ $suffix_pattern$ ]]; then | |
version="$curr_version-beta.$(date +%s)" | |
else | |
version="$curr_version" | |
fi | |
echo "version: ||$version||" | |
echo "Publishing a beta release: $version" | |
npm version "$version" --allow-same-version | |
npm i | |
npx tsc | |
npm publish --tag beta | |
fi |