-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (45 loc) · 1.36 KB
/
release-sdk.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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: Set up Node
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'
- name: Release
working-directory: code
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
curr_version="$(npm pkg get version | sed "s/\"//g")"
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 "Publishing a beta release: $version"
npm version "$version" --allow-same-version
npm i
npx tsc
npm publish --tag beta
fi