-
Notifications
You must be signed in to change notification settings - Fork 2
97 lines (90 loc) · 2.91 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# from node-osc package
# This is a basic workflow that is manually triggered
name: Bump version
# Controls when the action will run. Workflow runs when manually triggered using the UI
# or API.
on:
workflow_dispatch:
inputs:
release_version:
type: choice
description: 'The version to release will default to patch if not provided'
required: true
default: patch
options:
- patch
- minor
- major
- beta
- alpha
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
setup-node:
uses: ./.github/workflows/ci.yml
runs-on: ubuntu-latest
secrets: inherit
steps:
- uses: actions/checkout@v3
- name: Check out source
uses: actions/checkout@v3
with:
ssh-key: ${{ secrets.DEPLOY_KEY }}
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
bump-version:
needs: release-sdk
steps:
- name: Mark Git directory as Safe
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Bump version
id: bump_version
outputs:
version: ${{ steps.bump_version.outputs.version }}
run: |
if [[ "${{ github.event.inputs.version_override }}" == beta || "${{ github.event.inputs.version_override }}" == alpha ]]; then
npm version prerelease --preid="${{ github.event.inputs.version_override }}"
else
npm version "${{ github.event.inputs.version_override }}"
fi
version=$(cat package.json \
| grep version \
| head -1 \
| awk -F: '{ print $2 }' \
| sed 's/[",]//g')
echo "version=$version" >> $GITHUB_OUTPUT
publish:
name: Publish to npm
runs-on: ubuntu-latest
needs: bump-version
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16'
- name: Publish
run: |
npm config set //registry.npmjs.org/:_authToken ${PUBLISH_TOKEN}
npm ci
npm run build
npm publish
env:
NPM_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
create-github-release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: publish
steps:
- name: Push Tag
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git tag -a "${tag}" -m "${message}"
git push origin "${tag}"
env:
tag: v${{needs.bump-version.outputs.version}}
message: Release v${{needs.bump-version.outputs.version}}