From b73f84cd510a2bbdd3343478fc245c0144512bde Mon Sep 17 00:00:00 2001 From: Nour Alharithi Date: Thu, 7 Sep 2023 20:07:30 -0700 Subject: [PATCH] adding auto-bump worfklow --- .github/worfklows/on-sdk-update.yml | 71 +++++++++++++++++++++++++++++ tests/jit-proxy.ts | 16 ------- 2 files changed, 71 insertions(+), 16 deletions(-) create mode 100644 .github/worfklows/on-sdk-update.yml delete mode 100644 tests/jit-proxy.ts diff --git a/.github/worfklows/on-sdk-update.yml b/.github/worfklows/on-sdk-update.yml new file mode 100644 index 0000000..e4e4719 --- /dev/null +++ b/.github/worfklows/on-sdk-update.yml @@ -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 }} + + diff --git a/tests/jit-proxy.ts b/tests/jit-proxy.ts deleted file mode 100644 index a048d90..0000000 --- a/tests/jit-proxy.ts +++ /dev/null @@ -1,16 +0,0 @@ -import * as anchor from '@project-serum/anchor'; -import { Program } from '@project-serum/anchor'; -import { JitProxy } from '../target/types/jit_proxy'; - -describe('jit-proxy', () => { - // Configure the client to use the local cluster. - anchor.setProvider(anchor.AnchorProvider.env()); - - const program = anchor.workspace.JitProxy as Program; - - it('Is initialized!', async () => { - // Add your test here. - const tx = await program.methods.initialize().rpc(); - console.log('Your transaction signature', tx); - }); -}); \ No newline at end of file