diff --git a/.github/actions/setup-solana/action.yaml b/.github/actions/setup-solana/action.yaml deleted file mode 100644 index 1f4fb6c..0000000 --- a/.github/actions/setup-solana/action.yaml +++ /dev/null @@ -1,21 +0,0 @@ -name: "Setup Solana" -description: "Setup Solana" -runs: - using: "composite" - steps: - - uses: actions/cache@v2 - name: Cache Solana Tool Suite - id: cache-solana - with: - path: | - ~/.cache/solana/ - ~/.local/share/solana/ - key: solana-${{ runner.os }}-v0000-${{ env.SOLANA_CLI_VERSION }} - - run: sh -c "$(curl -sSfL https://release.solana.com/v${{ env.SOLANA_CLI_VERSION }}/install)" - shell: bash - - run: echo "/home/runner/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH - shell: bash - - run: solana-keygen new --no-bip39-passphrase - shell: bash - - run: solana config set --url localhost - shell: bash diff --git a/.github/actions/setup/action.yaml b/.github/actions/setup/action.yaml deleted file mode 100644 index adcc008..0000000 --- a/.github/actions/setup/action.yaml +++ /dev/null @@ -1,7 +0,0 @@ -name: "Setup" -description: "Setup" -runs: - using: "composite" - steps: - - run: sudo apt-get update && sudo apt-get install -y pkg-config build-essential libudev-dev - shell: bash diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml deleted file mode 100644 index 37f4e34..0000000 --- a/.github/workflows/build.yaml +++ /dev/null @@ -1,123 +0,0 @@ -name: Build -on: - push: - branches: - - master - pull_request: - branches: - - master -env: - SOLANA_CLI_VERSION: 1.16.17 -jobs: - build-and-test: - name: Build and test programs - runs-on: big-runner-1 - - steps: - # Setup - - uses: actions/checkout@v3 - with: - submodules: recursive - - uses: ./.github/actions/setup/ - - uses: ./.github/actions/setup-solana/ - - uses: actions/cache@v2 - name: Cache Cargo registry + index - id: cache-anchor - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - key: cargo-${{ runner.os }}-anchor-${{ hashFiles('**/Cargo.lock') }} - - run: cargo install --git https://github.com/coral-xyz/anchor --tag v0.29.0 anchor-cli --locked --force - working-directory: / - - name: Install latest nightly - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly-2023-10-05-x86_64-unknown-linux-gnu - components: rustfmt, clippy - - # --force is hack around cargo caching, figure out later - - name: Setup Rust tools - run: | - cargo +nightly-2023-10-05 install cargo-sort --force - cargo +nightly-2023-10-05 install cargo-udeps --force - shell: bash - - - name: cargo sort - run: cargo +nightly-2023-10-05 sort --workspace --check - shell: bash - - - name: cargo fmt - run: cargo +nightly-2023-10-05 fmt --all --check - shell: bash - - - name: clippy - run: cargo +nightly-2023-10-05 clippy --all-features --all-targets --tests -- -D warnings - shell: bash - - - name: cargo udeps - run: cargo +nightly-2023-10-05 udeps --all-features --all-targets --tests - shell: bash - - # Build IDLs - - name: Build merkle-distributor - run: anchor build --idl idl --program-name merkle_distributor - - # Make sure no uncommitted changes - - name: Check for diff - run: git diff --exit-code - - - name: cargo test - run: RUST_LOG=debug cargo test --all-targets --all-features --color auto - shell: bash - - verified-build: - name: Build Verifiable Artifact - runs-on: big-runner-1 - steps: - - uses: actions/checkout@v3 - with: - submodules: recursive - - # --force because the cargo cache has it saved - - name: Install Solana Verify - run: | - cargo install solana-verify --force - solana-verify --version - - - name: Verifiable Build - run: | - solana-verify build --library-name merkle_distributor - - - name: Upload Artifact - uses: actions/upload-artifact@v3 - with: - name: build - path: | - target/deploy/merkle_distributor.so - -# docker: -# name: Build and push docker container -# runs-on: big-runner-1 -# steps: -# # Required for docker cache export -# - name: Set up Docker Buildx -# uses: docker/setup-buildx-action@v2 -# -# - name: Login to Docker Hub -# uses: docker/login-action@v2 -# with: -# username: ${{ secrets.DOCKERHUB_USER }} -# password: ${{ secrets.DOCKERHUB_PWD }} -# -# - name: Build and push jito-airdrop-api -# uses: docker/build-push-action@v4 -# with: -# push: true -# target: jito-airdrop-api -# tags: jitolabs/jito-airdrop-api:${{ github.sha }} -# cache-from: type=gha -# cache-to: type=gha,mode=max -# platforms: linux/arm64,linux/x86_64 diff --git a/.github/workflows/mainnet-beta.yml b/.github/workflows/mainnet-beta.yml new file mode 100644 index 0000000..a1882d5 --- /dev/null +++ b/.github/workflows/mainnet-beta.yml @@ -0,0 +1,66 @@ +name: Distributor Build Image And Deploy + +on: + push: + branches: [mainnet-beta] + +jobs: + build: + runs-on: ubicloud + steps: + - name: Checkout Code + uses: actions/checkout@v3 + with: + submodules: 'recursive' + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@master + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_PROD }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY_PROD }} + aws-region: ${{ secrets.EKS_PROD_REGION }} + + - name: Log in to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v2 + + - name: Build and push + uses: docker/build-push-action@v6 + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: distributor-api + IMAGE_TAG: ${{ github.sha }} + BRANCH_NAME: ${{ github.ref_name }} + with: + context: . + push: true + tags: | + ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }}-${{ env.BRANCH_NAME }}-amd64 + ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:latest-${{ env.BRANCH_NAME }}-amd64 + + deploy: + runs-on: ubicloud + needs: [build] + steps: + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@master + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_PROD }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY_PROD }} + aws-region: ${{ secrets.EKS_PROD_REGION }} + + - name: Install kubectl + uses: azure/setup-kubectl@v3 + with: + version: 'v1.30.0' + + - name: Configure AWS EKS Credentials + run: aws eks update-kubeconfig --name ${{ secrets.EKS_PROD_CLUSTER_NAME }} --region ${{ secrets.EKS_PROD_REGION }} --role-arn ${{ secrets.EKS_PROD_DEPLOY_ROLE }} + + - name: Restart deployment + env: + BRANCH_NAME: ${{ github.ref_name }} + run: | + kubectl rollout restart -n $BRANCH_NAME statefulset/airdrop-distributor + kubectl rollout restart -n $BRANCH_NAME statefulset/airdrop-distributor-2 + kubectl rollout restart -n $BRANCH_NAME statefulset/airdrop-distributor-3 \ No newline at end of file diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml new file mode 100644 index 0000000..0809fb6 --- /dev/null +++ b/.github/workflows/master.yml @@ -0,0 +1,64 @@ +name: Distributor Build Image And Deploy + +on: + push: + branches: [master] + +jobs: + build: + runs-on: ubicloud + steps: + - name: Checkout Code + uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@master + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_NON_PROD }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY_NON_PROD }} + aws-region: ${{ secrets.EKS_NON_PROD_REGION }} + + - name: Log in to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v2 + + - name: Build and push + uses: docker/build-push-action@v6 + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: distributor-api + IMAGE_TAG: ${{ github.sha }} + BRANCH_NAME: ${{ github.ref_name }} + with: + context: . + push: true + tags: | + ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }}-${{ env.BRANCH_NAME }}-amd64 + ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:latest-${{ env.BRANCH_NAME }}-amd64 + + deploy: + runs-on: ubicloud + needs: [build] + steps: + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@master + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_NON_PROD }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY_NON_PROD }} + aws-region: ${{ secrets.EKS_NON_PROD_REGION }} + + - name: Install kubectl + uses: azure/setup-kubectl@v3 + with: + version: 'v1.30.0' + + - name: Configure AWS EKS Credentials + run: aws eks update-kubeconfig --name ${{ secrets.EKS_NON_PROD_CLUSTER_NAME }} --region ${{ secrets.EKS_NON_PROD_REGION }} --role-arn ${{ secrets.EKS_NON_PROD_DEPLOY_ROLE }} + + - name: Restart deployment + env: + BRANCH_NAME: ${{ github.ref_name }} + run: | + kubectl rollout restart -n $BRANCH_NAME statefulset/master-airdrop-distributor \ No newline at end of file diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml deleted file mode 100644 index 7c66a0b..0000000 --- a/.github/workflows/release.yaml +++ /dev/null @@ -1,72 +0,0 @@ -name: Release -on: - push: - tags: - - 'v*' - -env: - SOLANA_CLI_VERSION: 1.16.17 -jobs: - release: - name: Create the jito programs release - runs-on: big-runner-1 - - steps: - # Setup - - uses: actions/checkout@v3 - with: - submodules: recursive - - uses: ./.github/actions/setup/ - - uses: ./.github/actions/setup-solana/ - - uses: actions/cache@v2 - name: Cache Cargo registry + index - id: cache-anchor - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - key: cargo-${{ runner.os }}-anchor-${{ hashFiles('**/Cargo.lock') }} - - run: cargo install --git https://github.com/coral-xyz/anchor --tag v0.29.0 anchor-cli --locked --force - - # Build IDLs + programs - - name: Build program - run: anchor build --idl idl --program-name merkle_distributor - - # Verified build - # --force because the cargo cache has it saved - - name: Install Solana Verify - run: | - cargo install solana-verify --force - solana-verify --version - - - name: Verifiable Build - run: | - solana-verify build --library-name merkle_distributor - - # Make sure no uncommitted changes - - name: Check for diff - run: git diff --exit-code - - # Push to anchor repository -# - name: Anchor Login -# run: anchor login ${{ secrets.ANCHOR_PUBLISH_TOKEN }} -# - name: Publish merkle_distributor source code -# run: yes 'yes' | anchor publish merkle_distributor --skip-build --provider.cluster mainnet - - # Upload artifacts - - name: Upload Artifact - uses: actions/upload-artifact@v3 - with: - name: build - path: | - target/deploy/merkle_distributor.so - programs/merkle-distributor/idl/merkle_distributor.json - - name: Release - uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') - with: - files: | - target/deploy/merkle_distributor.so - programs/merkle-distributor/idl/merkle_distributor.json