Skip to content

Commit

Permalink
[api] fix deploy workflow (#198)
Browse files Browse the repository at this point in the history
  • Loading branch information
yurushao authored Aug 21, 2024
1 parent 7b6a977 commit 2d3af5d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy_api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ jobs:
echo " GIT_SHA: $GITHUB_SHA" >> api/.env.yaml
- name: Deploy to GAE
run: ./deploy_api.sh --${{ inputs.environment }}
run: ./scripts/deploy_api.sh --${{ inputs.environment }}
24 changes: 16 additions & 8 deletions scripts/mainnet_deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

set -e

PROGRAM_KEYPAIR=~/solana-keypairs/glam/glam-keypair-GLAMpLuXu78TA4ao3DPZvT1zQ7woxoQ8ahdYbhnqY9mP.json
SOLANA=~/code/agave/target/debug/solana
PRIORITY_FEE=50000
PROGRAM_KEYPAIR=
SOLANA=
PRIORITY_FEE=10000
MAX_ATTEMPTS=1000
PROGRAM_ID=GLAMpLuXu78TA4ao3DPZvT1zQ7woxoQ8ahdYbhnqY9mP

build() {
anchor build -- --features mainnet
Expand All @@ -19,17 +20,18 @@ deploy() {
--max-sign-attempts $MAX_ATTEMPTS
}

if [ -f $SOLANA ]; then
if [ -n "$SOLANA" ] && [ -f "$SOLANA" ]; then
echo "✅ Found solana binary: $SOLANA"
else
which solana > /dev/null || (echo "❌ Missing solana binary" && exit 1)
SOLANA=$(which solana)
echo "✅ Use solana binary at $SOLANA"
fi

$SOLANA address -k $PROGRAM_KEYPAIR >> /dev/null || (echo "❌ Missing program keypair" && exit 1)
if [ $($SOLANA address -k $PROGRAM_KEYPAIR) == "GLAMpLuXu78TA4ao3DPZvT1zQ7woxoQ8ahdYbhnqY9mP" ]; then
echo "✅ Program keypair is correct: $PROGRAM_KEYPAIR"
$SOLANA address -k $PROGRAM_KEYPAIR &> /dev/null || (echo "❌ Missing program keypair" && exit 1)
if [ $($SOLANA address -k $PROGRAM_KEYPAIR) == $PROGRAM_ID ]; then
echo "✅ Program keypair : $PROGRAM_KEYPAIR"
echo "✅ Program ID validated: $PROGRAM_ID"
else
echo "❌ Program keypair is incorrect" && exit 1
fi
Expand All @@ -41,7 +43,13 @@ else
fi

# anchor build will remove program id from the idl file, we need to restore it
(cd anchor && build) && git checkout anchor/target/idl/glam.json
(cd anchor && build)

size_kb=$(ls -lh anchor/target/deploy/glam.so | awk '{print $5}')
size_bytes=$(ls -l anchor/target/deploy/glam.so | awk '{print $5}')
echo "==== Program size ===="
echo "glam.so: $size_kb ($size_bytes bytes)"
echo "======================"

# Uncomment the following line to deploy the program
# deploy

0 comments on commit 2d3af5d

Please sign in to comment.