Skip to content

Commit

Permalink
trigger workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
vovacodes committed Nov 10, 2023
1 parent f1eedb0 commit 4ea990a
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 24 deletions.
19 changes: 11 additions & 8 deletions .github/actions/build-anchor/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ inputs:
program:
description: "The program to build"
required: true
program_id_replacement:
description: "The program ID to replace in the lib.rs file, e.g. when deploying to a staging address."
program_id:
description: "The program address"
required: true
replace_program_id:
description: "Whether to replace current program id with `program_id` in lib.rs, e.g. when deploying to a staging address"

runs:
using: "composite"
steps:
- name: Cache Anchor build
uses: actions/cache@v2
uses: actions/cache@v3
id: cache-anchor-build
if: env.CACHE != 'true' || steps.cache-anchor-build.outputs.cache-hit != 'true'
with:
Expand All @@ -20,11 +23,11 @@ runs:
key: build-${{ runner.os }}-${{env.ANCHOR_VERSION}}-${{ hashFiles(format('./programs/{0}/**', inputs.program)) }}-${{ inputs.program }}-${{ inputs.staging }}

- name: Replace program ID if needed
if: inputs.program_id_replacement != ''
if: inputs.replace_program_id == 'true'
env:
PROGRAM_ID: ${{ inputs.program_id_replacement }}
PROGRAM_ID: ${{ inputs.program_id }}
run: |
sed -i "" "s/declare_id!(\".*\")/declare_id!(\"${PROGRAM_ID}\")/g" ./programs/${{ inputs.program }}/src/lib.rs
sed -i "s/declare_id!(\".*\")/declare_id!(\"${PROGRAM_ID}\")/g" ./programs/${{ inputs.program }}/src/lib.rs
shell: bash

- name: Build with Anchor
Expand All @@ -36,11 +39,11 @@ runs:
with:
name: ${{inputs.program}}-so
path: |
./target/deploy/${{env.PROGRAM_NAME}}.so
./target/deploy/${{inputs.program}}.so
- name: Store IDL files
uses: actions/upload-artifact@v3
with:
name: ${{inputs.program}}-idl
path: |
./target/idl/${{env.PROGRAM_NAME}}.json
./target/idl/${{inputs.program}}.json
31 changes: 27 additions & 4 deletions .github/actions/deploy-anchor/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ inputs:
program:
description: "The program to build"
required: true
program_id:
description: "The program address"
required: true
rpc_url:
description: "The RPC url for the cluster to deploy to"
required: true
Expand All @@ -15,12 +18,32 @@ inputs:
runs:
using: "composite"
steps:
- name: Deploy with Anchor
- name: Save Upgrade Authority keypair on disk
run: |
echo $UPGRADE_AUTHORITY_KEYPAIR > ./upgrade-authority.json && chmod 600 ./upgrade-authority.json
~/.cargo/bin/anchor deploy --provider.cluster $RPC_URL --provider.wallet ./upgrade-authority.json --program-name ${{ inputs.program }}
rm ./upgrade-authority.json
shell: bash
env:
RPC_URL: ${{ inputs.rpc_url }}
UPGRADE_AUTHORITY_KEYPAIR: ${{ inputs.upgrade_authority_keypair }}

- name: Deploy .so with Anchor
run: |
~/.cargo/bin/anchor upgrade --program-id $PROGRAM_ID --provider.cluster $RPC_URL --provider.wallet ./upgrade-authority.json ./target/deploy/${PROGRAM_NAME}.so
shell: bash
env:
RPC_URL: ${{ inputs.rpc_url }}
PROGRAM_NAME: ${{ inputs.program }}
PROGRAM_ID: ${{ inputs.program_id }}

- name: Deploy IDL with Anchor
run: |
anchor idl upgrade --provider.cluster $RPC_URL --provider.wallet ./upgrade-authority.json --filepath target/idl/${PROGRAM_NAME}.json $PROGRAM_ID
shell: bash
env:
RPC_URL: ${{ inputs.rpc_url }}
PROGRAM_NAME: ${{ inputs.program }}
PROGRAM_ID: ${{ inputs.program_id }}

- name: Remove Upgrade Authority keypair from disk
run: |
rm ./upgrade-authority.json
shell: bash
7 changes: 6 additions & 1 deletion .github/workflows/check-staging-deployer-balance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ jobs:
if: contains(github.event.pull_request.labels.*.name, 'deploy-staging')
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Solana
uses: ./.github/actions/setup-solana/

Expand All @@ -39,6 +42,8 @@ jobs:
# Check if the balance is less than the minimum balance using floating point comparison with `bc`
if (( $(echo "$BALANCE < $MIN_BALANCE" | bc -l) )); then
echo "Balance of $PUBLIC_KEY is less than $MIN_BALANCE SOL"
echo "Balance of $PUBLIC_KEY is $BALANCE, which is less than the minimum balance of $MIN_BALANCE"
exit 1
fi
echo "Balance of $PUBLIC_KEY is $BALANCE SOL"
3 changes: 2 additions & 1 deletion .github/workflows/publish-staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ jobs:
solana_cli_version: 1.17.0
anchor_version: 0.29.0
program: "squads_multisig_program"
program_id_replacement: "STAG3xkFMyVK3sRtQhipsKuLpRGbgospDpVdNyJqDpS"
program_id: "STAG3xkFMyVK3sRtQhipsKuLpRGbgospDpVdNyJqDpS"
replace_program_id: true
secrets:
RPC_URL: ${{ secrets.RPC_URL_MAINNET }}
UPGRADE_AUTHORITY_KEYPAIR: ${{ secrets.UPGRADE_AUTHORITY_KEYPAIR_STAGING }}
25 changes: 15 additions & 10 deletions .github/workflows/reusable-publish-staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ on:
description: "The program to build"
required: true
type: string
program_id_replacement:
description: "The program ID to replace in the lib.rs file, e.g. when deploying to a staging address."
required: false
program_id:
description: "The program address"
required: true
type: string
replace_program_id:
description: "Whether to replace current program id with `program_id` in lib.rs, e.g. when deploying to a staging address"
type: boolean

secrets:
RPC_URL:
Expand Down Expand Up @@ -56,13 +59,15 @@ jobs:
uses: ./.github/actions/build-anchor/
with:
program: ${{ inputs.program }}
program_id_replacement: ${{ inputs.program_id_replacement }}
program_id: ${{ inputs.program_id }}
replace_program_id: ${{ inputs.replace_program_id }}

# - name: Deploy with Anchor
# uses: ./.github/actions/deploy-anchor/
# with:
# program: ${{ inputs.program }}
# rpc_url: ${{ secrets.RPC_URL }}
# upgrade_authority_keypair: ${{ secrets.UPGRADE_AUTHORITY_KEYPAIR }}
- name: Deploy with Anchor
uses: ./.github/actions/deploy-anchor/
with:
program: ${{ inputs.program }}
program_id: ${{ inputs.program_id }}
rpc_url: ${{ secrets.RPC_URL }}
upgrade_authority_keypair: ${{ secrets.UPGRADE_AUTHORITY_KEYPAIR }}


1 change: 1 addition & 0 deletions programs/squads_multisig_program/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ default = []
anchor-lang = { version = "=0.29.0", features = ["allow-missing-optionals"] }
anchor-spl = { version="=0.29.0", features=["token"] }
solana-security-txt = "1.1.1"
#
1 change: 1 addition & 0 deletions sdk/multisig/.solitarc.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const keypair = loadKeypairFromFile(
);

const pubkey = keypair.publicKey.toBase58();
console.log("Generating SDK for Program ID:", pubkey);

module.exports = {
idlGenerator: "anchor",
Expand Down

0 comments on commit 4ea990a

Please sign in to comment.