sdk-update #131
This file contains hidden or 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: Bump program IDL | |
on: | |
repository_dispatch: | |
types: ['sdk-update'] | |
jobs: | |
check-version: | |
runs-on: ubicloud | |
outputs: | |
idl_version: ${{ steps.version-check.outputs.idl_version }} | |
proceed: ${{ steps.version-check.outputs.proceed }} | |
steps: | |
- name: Check update version | |
id: version-check | |
run: | | |
VERSION=$(curl -s "https://api.github.com/repos/drift-labs/protocol-v2/tags" | grep -m 1 "name" | cut -d '"' -f 4) | |
echo "idl_version=$VERSION" >> $GITHUB_OUTPUT | |
# Check if version contains beta, alpha, or rc tags | |
if echo "$VERSION" | grep -qE "beta|alpha|rc"; then | |
echo "proceed=false" >> $GITHUB_OUTPUT | |
echo "Skipping PR creation for pre-release version: $VERSION" | |
else | |
echo "proceed=true" >> $GITHUB_OUTPUT | |
fi | |
update-idl: | |
needs: check-version | |
if: needs.check-version.outputs.proceed == 'true' | |
runs-on: ubicloud | |
permissions: | |
contents: write | |
pull-requests: write | |
env: | |
CARGO_DRIFT_FFI_PATH: /usr/lib | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Update IDL | |
run: | | |
curl -H 'Accept: application/vnd.github.v3.raw' 'https://api.github.com/repos/drift-labs/protocol-v2/contents/sdk/src/idl/drift.json?ref=tags/${{ needs.check-version.outputs.idl_version }}' > res/drift.json | |
- name: Setup Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: stable | |
- name: Generate Rust types | |
run: | | |
# libdrift install | |
SO_URL=$(curl -s https://api.github.com/repos/drift-labs/drift-ffi-sys/releases/latest | jq -r '.assets[] | select(.name=="libdrift_ffi_sys.so") | .browser_download_url') | |
echo "downloading libdrift: $SO_URL" | |
curl -L -o libdrift_ffi_sys.so "$SO_URL" | |
sudo cp libdrift_ffi_sys.so $CARGO_DRIFT_FFI_PATH && rm libdrift_ffi_sys.so | |
cargo check | |
- name: Git config | |
run: | | |
git config user.name "GitHub Actions" | |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
- name: Commit changes | |
run: | | |
# Create branch and commit changes (don't fail if it exists) | |
git checkout -b bump/idl-${{ needs.check-version.outputs.idl_version }} || true | |
git add -u | |
git commit -m "chore: bump IDL to ${{ needs.check-version.outputs.idl_version }}" | |
git push origin bump/idl-${{ needs.check-version.outputs.idl_version }} -f | |
- name: Create PR | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
PR_EXISTS=$(gh pr list --head "bump/idl-${{ needs.check-version.outputs.idl_version }}" --json number | jq 'length') | |
if [ "$PR_EXISTS" -gt 0 ]; then | |
echo "PR for version ${{ needs.check-version.outputs.idl_version }} already exists, skipping PR creation" | |
else | |
gh pr create \ | |
--title "Bump IDL to ${{ needs.check-version.outputs.idl_version }}" \ | |
--body "Automatic IDL update for program ${{ needs.check-version.outputs.idl_version }}" \ | |
--label "idl" \ | |
--base main \ | |
--head bump/idl-${{ needs.check-version.outputs.idl_version }} | |
fi |