Skip to content

competitions-sdk-update #512

competitions-sdk-update

competitions-sdk-update #512

Workflow file for this run

name: Deploy on sdk update
on:
push:
branches:
- master
repository_dispatch:
types: [competitions-sdk-update]
env:
CARGO_TERM_COLOR: always
RUST_TOOLCHAIN: 1.70.0
SOLANA_VERSION: "1.16.27"
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 "DRIFT_SDK_VERSION=${{ github.event.client_payload.sdk-version }}" >> $GITHUB_ENV
echo "COMPETITIONS_SDK_VERSION=${{ github.event.client_payload.competitions-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/competitions-sdk@$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: Check Rust version
run: rustc --version
- name: Install Rust nightly
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
profile: minimal
override: true
components: rustfmt, clippy
- 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
yarn run prettify:fix
git add -A
git commit --allow-empty -m "Bumping sdk and competitions-sdk dependencies to $DRIFT_SDK_VERSION and $COMPETITIONS_SDK_VERSION"
git push
echo "VAULT_VERSION=$VERSION" >> $GITHUB_ENV
- 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/internal-keeper-bot/dispatches" \
-d "{\"event_type\": \"jit-sdk-update\", \"client_payload\": {
\"sdk-version\": \"$SDK_VERSION\",
\"vault-version\": \"$VAULT_VERSION\"
}}"
env:
GH_PAT: ${{ secrets.GH_PAT }}