Chore/publish 0.0.12 #83
This file contains 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: Deploy Programs to devnet | |
env: | |
SOLANA_CLI_VERSION: 1.16.13 | |
NODE_VERSION: 18.12.1 | |
on: | |
push: | |
branches: | |
- develop | |
pull_request: | |
branches: | |
- develop | |
jobs: | |
detect_changed_programs: | |
if: github.event_name == 'push' || contains(github.event.pull_request.labels.*.name, 'deploy-to-devnet') | |
runs-on: ubuntu-latest | |
outputs: | |
programs_with_changes: ${{ steps.list_changed_programs.outputs.programs_with_changes }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }} | |
- name: List changed programs | |
id: list_changed_programs | |
run: | | |
echo "Detecting changes in programs" | |
# Use git diff to get a list of changed programs and output it as JSON | |
changed_files=$(git diff --name-only ${{ (github.event_name == 'pull_request' && github.event.pull_request.base.sha) || github.event.before }} ${{ github.event.after }}) | |
changed_programs=($(echo "$changed_files" | grep "^programs/" | grep -v "/shared-utils/" | cut -d '/' -f 2 | sort -u)) | |
echo "${changed_programs[@]}" | |
json="[$(printf "'%s'", "${changed_programs[@]}" | sed 's/,$//')]" | |
echo $json | |
echo "programs_with_changes=$json" >> $GITHUB_OUTPUT | |
build_programs: | |
needs: [detect_changed_programs] | |
continue-on-error: true | |
runs-on: ubuntu-latest | |
if: needs.detect_changed_programs.outputs.programs_with_changes != '[]' && needs.detect_changed_programs.outputs.programs_with_changes != '' | |
strategy: | |
matrix: | |
program: ${{ fromJson(needs.detect_changed_programs.outputs.programs_with_changes) }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set devnet lazy signer | |
run: | | |
find programs -type f -name '*.rs' -exec sed -i "s/b\"nJWGUMOK\"/b\"devnethelium5\"/g" {} \; | |
- uses: actions/cache@v2 | |
name: Cache Toml Cli | |
id: cache-toml-cli | |
with: | |
path: | | |
~/.cargo/bin/toml | |
key: toml-cli-${{ runner.os }}-v0002 | |
- run: (cargo install toml-cli || true) | |
if: steps.cache-toml-cli.outputs.cache-hit != 'true' | |
shell: bash | |
- name: Set program information | |
if: steps.cache-toml.outputs.cache-hit != 'true' | |
run: | | |
PROGRAM_NAME=${PROGRAM//-/_} # Substitute dashes with underscores | |
PROGRAM_ID=$(~/.cargo/bin/toml get Anchor.toml programs.localnet.${PROGRAM_NAME} | tr -d '"') | |
echo "Program: $PROGRAM_ID" | |
echo "PROGRAM_NAME=${PROGRAM_NAME}" >> $GITHUB_ENV | |
echo "PROGRAM_ID=${PROGRAM_ID}" >> $GITHUB_ENV | |
env: | |
PROGRAM: ${{ matrix.program }} | |
# Build the program with anchor so we get the IDL | |
- uses: ./.github/actions/build-anchor/ | |
id: build-anchor | |
with: | |
testing: false | |
devnet: true | |
program: ${{ env.PROGRAM_NAME }} | |
- uses: ./.github/actions/build-verified/ | |
id: build-verified | |
with: | |
devnet: true | |
program: ${{ env.PROGRAM_NAME }} | |
program-id: ${{ env.PROGRAM_ID }} | |
- name: Store so files | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{matrix.program}}-so | |
path: | | |
./target/deploy/${{env.PROGRAM_NAME}}.so | |
- name: Store idl files | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{matrix.program}}-idl | |
path: | | |
./target/idl/${{env.PROGRAM_NAME}}.json | |
publish_programs: | |
continue-on-error: true | |
needs: [detect_changed_programs, build_programs] | |
runs-on: ubuntu-latest | |
if: needs.detect_changed_programs.outputs.programs_with_changes != '[]' && needs.detect_changed_programs.outputs.programs_with_changes != '' | |
strategy: | |
# Publish must happen one at a time or there can be conflicts | |
max-parallel: 1 | |
matrix: | |
program: ${{ fromJson(needs.detect_changed_programs.outputs.programs_with_changes) }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- uses: ./.github/actions/setup-anchor/ | |
- name: Set program information | |
if: steps.cache-toml.outputs.cache-hit != 'true' | |
run: | | |
PROGRAM_NAME=${PROGRAM//-/_} # Substitute dashes with underscores | |
PROGRAM_ID=$(~/.cargo/bin/toml get Anchor.toml programs.localnet.${PROGRAM_NAME} | tr -d '"') | |
echo "Program: $PROGRAM_ID" | |
echo "PROGRAM_NAME=${PROGRAM_NAME}" >> $GITHUB_ENV | |
echo "PROGRAM_ID=${PROGRAM_ID}" >> $GITHUB_ENV | |
env: | |
PROGRAM: ${{ matrix.program }} | |
- name: Download a so files | |
uses: actions/download-artifact@v3 | |
with: | |
name: ${{matrix.program}}-so | |
path: ./target/deploy/ | |
- name: Download idl files | |
uses: actions/download-artifact@v3 | |
with: | |
name: ${{matrix.program}}-idl | |
path: ./target/idl/ | |
- uses: ./.github/actions/buffer-deploy/ | |
id: buffer-deploy | |
with: | |
devnet: true | |
network: devnet | |
program: ${{ env.PROGRAM_NAME }} | |
keypair: ${{ secrets.DEVNET_DEPLOYER_KEYPAIR }} | |
program-id: ${{ env.PROGRAM_ID }} | |
buffer-authority: ${{ secrets.DEVNET_MULTISIG_VAULT }} | |
- name: Squads program upgrade | |
uses: helium/squads-program-upgrade@v0.3.1 | |
with: | |
network-url: "https://api.devnet.solana.com" | |
program-multisig: ${{ secrets.DEVNET_MULTISIG }} | |
program-id: ${{ env.PROGRAM_ID }} | |
buffer: ${{ steps.buffer-deploy.outputs.buffer }} | |
idl-buffer: ${{ steps.buffer-deploy.outputs.idl-buffer }} | |
spill-address: ${{ secrets.DEVNET_DEPLOYER_ADDRESS }} | |
authority: ${{ secrets.DEVNET_MULTISIG_VAULT }} | |
name: "Deploy ${{ matrix.program }}" | |
keypair: ${{ secrets.DEVNET_DEPLOYER_KEYPAIR }} |