-
Notifications
You must be signed in to change notification settings - Fork 3
78 lines (68 loc) · 2.51 KB
/
on-sdk-update.yml
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
name: Deploy on sdk update
on:
push:
branches:
- master
repository_dispatch:
types: [sdk-update]
jobs:
update-sdk:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: "16.x"
registry-url: "https://registry.npmjs.org"
- name: Determine sdk version
id: determine-sdk-version
run: |
if [[ "${{ github.event_name }}" == "repository_dispatch" ]]; then
echo "SDK_VERSION=${{ github.event.client_payload.version }}" >> $GITHUB_ENV
else
# Get the current version of sdk used in package.json
CURRENT_VERSION=$(node -e "console.log(require('./ts/sdk/package.json').dependencies['@drift-labs/sdk'])")
echo "SDK_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV
fi
- name: Install dependencies
run: yarn
working-directory: ts/sdk
- name: Add specific version of sdk
run: yarn add @drift-labs/sdk@$SDK_VERSION
working-directory: ts/sdk
- run: yarn build
working-directory: ts/sdk
- name: Update package version
run: npm version patch
working-directory: ts/sdk
- name: Git commit
id: publish-competitions-sdk
run: |
VERSION=$(node -e "console.log(require('./package.json').version);")
git config user.name "GitHub Actions"
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
git add -A
git commit --allow-empty -m "sdk: release v$VERSION"
git push origin HEAD
echo "COMPETITIONS_VERSION=$VERSION" >> $GITHUB_ENV
working-directory: ts/sdk
- name: Publish to npm
run: npm publish --access=public
working-directory: ts/sdk
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Emit dispatch event
run: |
curl -X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: token ${{ secrets.GH_PAT }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/drift-labs/drift-vaults/dispatches" \
-d "{\"event_type\": \"competitions-sdk-update\", \"client_payload\": {
\"sdk-version\": \"$SDK_VERSION\",
\"competitions-version\": \"$COMPETITIONS_VERSION\"
}}"
env:
GH_PAT: ${{ secrets.GH_PAT }}