|
| 1 | +name: "Upload BPF" |
| 2 | +description: "Uploads an anchor program as a bpf" |
| 3 | +inputs: |
| 4 | + devnet: |
| 5 | + description: "Whether to use devnet feature" |
| 6 | + required: false |
| 7 | + default: "false" |
| 8 | + testing: |
| 9 | + description: "Whether to use devnet feature" |
| 10 | + required: false |
| 11 | + default: "false" |
| 12 | + network: |
| 13 | + description: "The Solana network" |
| 14 | + required: true |
| 15 | + default: "devnet" |
| 16 | + program: |
| 17 | + description: "The program to build and upload" |
| 18 | + required: true |
| 19 | + program-id: |
| 20 | + description: "The program id of the program we are uploading" |
| 21 | + required: true |
| 22 | + keypair: |
| 23 | + description: "The keypair to use for deploys" |
| 24 | + required: true |
| 25 | + buffer-authority: |
| 26 | + description: "The buffer authority to set" |
| 27 | + required: true |
| 28 | +outputs: |
| 29 | + buffer: |
| 30 | + description: "The buffer address" |
| 31 | + value: ${{ steps.buffer-deploy-store.outputs.BUFFER }} |
| 32 | + idl-buffer: |
| 33 | + description: "The idl buffer address." |
| 34 | + value: ${{ steps.buffer-deploy-store.outputs.IDL_BUFFER }} |
| 35 | + |
| 36 | +runs: |
| 37 | + using: "composite" |
| 38 | + steps: |
| 39 | + - uses: ./.github/actions/setup/ |
| 40 | + - uses: ./.github/actions/setup-anchor/ |
| 41 | + with: |
| 42 | + node-version: ${{ env.NODE_VERSION }} |
| 43 | + - run: echo "$DEPLOY_KEYPAIR" > ./deploy-keypair.json && chmod 600 ./deploy-keypair.json |
| 44 | + shell: bash |
| 45 | + env: |
| 46 | + DEPLOY_KEYPAIR: ${{ inputs.keypair }} |
| 47 | + working-directory: solana-programs |
| 48 | + - run: solana-keygen new -s -o keyp --no-bip39-passphrase |
| 49 | + working-directory: solana-programs |
| 50 | + shell: bash |
| 51 | + - run: ls -l ./target/deploy/ |
| 52 | + shell: bash |
| 53 | + working-directory: solana-programs |
| 54 | + - name: Buffer Deploy |
| 55 | + if: steps.cache-buffer.outputs.cache-hit != 'true' |
| 56 | + id: buffer-deploy |
| 57 | + uses: nick-invision/retry@v2 |
| 58 | + with: |
| 59 | + timeout_minutes: 30 |
| 60 | + max_attempts: 10 |
| 61 | + shell: bash |
| 62 | + command: cd solana-programs && solana program write-buffer --max-sign-attempts 50 --with-compute-unit-price 100000 --use-rpc --buffer ./keyp -k ./deploy-keypair.json ./target/deploy/$PROGRAM.so -u $NETWORK > ./buffer.out |
| 63 | + env: |
| 64 | + NETWORK: ${{ inputs.network }} |
| 65 | + PROGRAM: ${{ inputs.program }} |
| 66 | + - name: IDL Buffer Deploy |
| 67 | + uses: nick-invision/retry@v2 |
| 68 | + id: idl-buffer-deploy |
| 69 | + if: steps.cache-buffer.outputs.cache-hit != 'true' |
| 70 | + with: |
| 71 | + timeout_minutes: 10 |
| 72 | + max_attempts: 50 |
| 73 | + shell: bash |
| 74 | + command: cd solana-programs && ~/.cargo/bin/anchor idl write-buffer $PROGRAM_ID --filepath ./target/idl/$PROGRAM.json --provider.cluster $NETWORK --provider.wallet ./deploy-keypair.json > idl-buffer.out |
| 75 | + env: |
| 76 | + PROGRAM_ID: ${{ inputs.program-id }} |
| 77 | + PROGRAM: ${{ inputs.program }} |
| 78 | + NETWORK: ${{ inputs.network }} |
| 79 | + - name: Buffer Deploy Store |
| 80 | + shell: bash |
| 81 | + working-directory: solana-programs |
| 82 | + id: buffer-deploy-store |
| 83 | + run: | |
| 84 | + echo "BUFFER=$(cat buffer.out | sed 's/Buffer: //g' | xargs echo -n)" >> $GITHUB_OUTPUT |
| 85 | + echo "IDL_BUFFER=$(tail -n 1 idl-buffer.out | sed 's/Idl buffer created: //g' | xargs echo -n)" >> $GITHUB_OUTPUT |
| 86 | + - run: echo "The buffer is ${{ steps.buffer-deploy-store.outputs.BUFFER }}" |
| 87 | + shell: bash |
| 88 | + working-directory: solana-programs |
| 89 | + - run: echo "the idl buffer is ${{ steps.buffer-deploy-store.outputs.IDL_BUFFER }}" |
| 90 | + shell: bash |
| 91 | + working-directory: solana-programs |
| 92 | + - name: Transfer idl buffer to authority |
| 93 | + uses: nick-invision/retry@v2 |
| 94 | + if: steps.cache-buffer.outputs.cache-hit != 'true' |
| 95 | + with: |
| 96 | + timeout_minutes: 10 |
| 97 | + max_attempts: 50 |
| 98 | + shell: bash |
| 99 | + command: cd solana-programs && anchor idl set-authority $IDL_BUFFER --provider.cluster $NETWORK --program-id $PROGRAM_ID --new-authority $AUTHORITY --provider.wallet ./deploy-keypair.json |
| 100 | + env: |
| 101 | + IDL_BUFFER: ${{ steps.buffer-deploy-store.outputs.IDL_BUFFER }} |
| 102 | + AUTHORITY: ${{ inputs.buffer-authority }} |
| 103 | + NETWORK: ${{ inputs.network }} |
| 104 | + PROGRAM_ID: ${{ inputs.program-id }} |
| 105 | + - name: Transfer buffer to authority |
| 106 | + uses: nick-invision/retry@v2 |
| 107 | + if: steps.cache-buffer.outputs.cache-hit != 'true' |
| 108 | + with: |
| 109 | + timeout_minutes: 10 |
| 110 | + max_attempts: 50 |
| 111 | + shell: bash |
| 112 | + command: cd solana-programs && solana program set-buffer-authority $BUFFER -k ./deploy-keypair.json --new-buffer-authority $AUTHORITY -u $NETWORK |
| 113 | + env: |
| 114 | + BUFFER: ${{ steps.buffer-deploy-store.outputs.BUFFER }} |
| 115 | + AUTHORITY: ${{ inputs.buffer-authority }} |
| 116 | + NETWORK: ${{ inputs.network }} |
| 117 | + - run: rm ./deploy-keypair.json |
| 118 | + shell: bash |
| 119 | + if: always() |
| 120 | + working-directory: solana-programs |
0 commit comments