-
Notifications
You must be signed in to change notification settings - Fork 16
68 lines (59 loc) · 2.45 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
name: Deploy on sdk update
on:
push:
branches:
- master
repository_dispatch:
types: [competitions-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 "DRIFT_SDK_VERSION=${{ github.event.client_payload.version }}" >> $GITHUB_ENV
echo "COMPETITIONS_SDK_VERSION=${{ github.event.client_payload.version }}" >> $GITHUB_ENV
else
# Get the current version of sdk used in package.json
CURRENT_DRIFT_SDK_VERSION=$(node -e "console.log(require('./ts/sdk/package.json').dependencies['@drift-labs/sdk'])")
CURRENT_COMPETITIONS_SDK_VERSION=$(node -e "console.log(require('./package.json').devDependencies['@drift-labs/competitions-sdk'])")
echo "DRIFT_SDK_VERSION=$CURRENT_DRIFT_SDK_VERSION" >> $GITHUB_ENV
echo "COMPETITIONS_SDK_VERSION=$CURRENT_COMPETITIONS_SDK_VERSION" >> $GITHUB_ENV
fi
- name: Install dependencies
run: yarn install
- name: Add specific version of sdk
run: |
yarn add --dev @drift-labs/sdk@$DRIFT_SDK_VERSION
yarn add --dev @drift-labs/drift-competitions@$COMPETITIONS_SDK_VERSION
cd ts/sdk
yarn add @drift-labs/sdk@$DRIFT_SDK_VERSION
- name: Build after new dependency
run: yarn run build
working-directory: ts/sdk
- name: Update package version
run: npm version patch
working-directory: ts/sdk
- name: Commit and push changes
id: publish-vaults-sdk
run: |
VERSION=$(node -e "console.log(require('./ts/sdk/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 "Bumping sdk and drift-competitions dependencies to $DRIFT_SDK_VERSION and $COMPETITIONS_SDK_VERSION"
git push
- name: Publish to npm
run: npm publish --access=public
working-directory: ts/sdk
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}