sdk-update #676
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: Deploy on sdk update | |
on: | |
push: | |
branches: | |
- master | |
repository_dispatch: | |
types: [sdk-update] | |
jobs: | |
update-sdk: | |
runs-on: ubicloud | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Setup node | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '18.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-jit-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 "JIT_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/keeper-bots-v2/dispatches" \ | |
-d "{\"event_type\": \"jit-sdk-update\", \"client_payload\": { | |
\"sdk-version\": \"$SDK_VERSION\", | |
\"jit-version\": \"$JIT_VERSION\" | |
}}" | |
env: | |
GH_PAT: ${{ secrets.GH_PAT }} | |