|
| 1 | +permissions: |
| 2 | + contents: read |
| 3 | +name: Solana Verified Build |
| 4 | + |
| 5 | +on: |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + sha: |
| 9 | + description: 'SHA to build (can be short)' |
| 10 | + required: true |
| 11 | + type: string |
| 12 | + push: |
| 13 | + branches: |
| 14 | + - develop |
| 15 | + |
| 16 | +jobs: |
| 17 | + changes: |
| 18 | + name: Detect changes |
| 19 | + runs-on: ubuntu-latest |
| 20 | + outputs: |
| 21 | + solana_changes: ${{ steps.changes.outputs.solana_changes }} |
| 22 | + steps: |
| 23 | + - name: Checkout the repo |
| 24 | + uses: actions/checkout@v4 |
| 25 | + with: |
| 26 | + persist-credentials: false |
| 27 | + - name: Detect changes |
| 28 | + uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 |
| 29 | + id: changes |
| 30 | + with: |
| 31 | + list-files: "shell" |
| 32 | + filters: | |
| 33 | + solana_changes: |
| 34 | + - 'contracts/**' |
| 35 | + - '.github/workflows/solana*.yml' |
| 36 | +
|
| 37 | + build: |
| 38 | + needs: [ changes ] |
| 39 | + if: ${{ needs.changes.outputs.solana_changes == 'true' }} |
| 40 | + runs-on: ubuntu-latest-8cores-32GB |
| 41 | + permissions: |
| 42 | + contents: write |
| 43 | + steps: |
| 44 | + - uses: actions/checkout@v4 |
| 45 | + with: |
| 46 | + fetch-depth: 0 |
| 47 | + - name: Get Long and Short SHAs |
| 48 | + id: get_sha |
| 49 | + run: | |
| 50 | + set -euo pipefail |
| 51 | + TARGET_SHA="${{ github.event_name == 'workflow_dispatch' && github.event.inputs.sha || github.sha }}" |
| 52 | + FULL_SHA="$(git rev-parse "${TARGET_SHA}")" |
| 53 | + { |
| 54 | + echo "short_sha=${FULL_SHA:0:12}" |
| 55 | + echo "full_sha=${FULL_SHA}" |
| 56 | + } >> "$GITHUB_OUTPUT" |
| 57 | + - uses: actions/checkout@v4 |
| 58 | + with: |
| 59 | + ref: ${{ steps.get_sha.outputs.full_sha }} |
| 60 | + fetch-depth: 0 |
| 61 | + - uses: actions-rust-lang/setup-rust-toolchain@9399c7bb15d4c7d47b27263d024f0a4978346ba4 # v1 |
| 62 | + - name: Install Solana Verify |
| 63 | + run: | |
| 64 | + cargo install solana-verify@0.4.6 |
| 65 | + - name: Cache cargo target dir |
| 66 | + id: cache-target |
| 67 | + uses: actions/cache@v4 # v4 |
| 68 | + with: |
| 69 | + path: /contracts/target/deploy/*.so |
| 70 | + key: ${{ runner.os }}-solana-contract-verified-${{ hashFiles('contracts/**/*.rs', 'contracts/**/Cargo.lock') }} |
| 71 | + - name: Build Verified Artifacts |
| 72 | + if: steps.cache-target.outputs.cache-hit != 'true' |
| 73 | + run: | |
| 74 | + cd contracts |
| 75 | + solana-verify build |
| 76 | + - name: Generate release files |
| 77 | + run: | |
| 78 | + cd contracts |
| 79 | + tar cfvz artifacts.tar.gz target/deploy/*.so target/idl/* |
| 80 | + - name: Publish Release |
| 81 | + uses: softprops/action-gh-release@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda # v2.2.1 |
| 82 | + with: |
| 83 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 84 | + tag_name: solana-artifacts-localtest-${{ steps.get_sha.outputs.short_sha }} |
| 85 | + target_commitish: ${{ steps.get_sha.outputs.full_sha }} |
| 86 | + files: | |
| 87 | + contracts/artifacts.tar.gz |
0 commit comments