Skip to content

Commit

Permalink
adding auto-bump worfklow
Browse files Browse the repository at this point in the history
  • Loading branch information
NourAlharithi committed Sep 8, 2023
1 parent 0bbb164 commit b73f84c
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 16 deletions.
71 changes: 71 additions & 0 deletions .github/worfklows/on-sdk-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
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 "::set-output name=version::${{ github.event.client_payload.version }}"
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 "::set-output name=version::$CURRENT_VERSION"
fi
- name: Install dependencies
run: yarn

- name: Add specific version of sdk
run: yarn add @drift-labs/sdk@${{ steps.determine-sdk-version.outputs.version }}

- run: yarn build
- name: Update package version
run: npm version patch
- name: Git commit
id: publish-jit-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 "sdk: release v$VERSION"
git push origin HEAD
echo "::set-output name=jit-version::$VERSION"
- name: Publish to npm
run: npm publish --access=public
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\": \"${{ steps.determine-sdk-version.outputs.version }}\",
\"jit-version\": \"${{ steps.publish-jit-sdk.outputs.version }}\"
}}"
env:
GH_PAT: ${{ secrets.GH_PAT }}


16 changes: 0 additions & 16 deletions tests/jit-proxy.ts

This file was deleted.

0 comments on commit b73f84c

Please sign in to comment.