diff --git a/.github/actions/install-solana/action.yml b/.github/actions/install-solana/action.yml new file mode 100644 index 0000000..5fbd040 --- /dev/null +++ b/.github/actions/install-solana/action.yml @@ -0,0 +1,65 @@ +name: Install Solana + +inputs: + version: + description: The Solana version to install + required: true + default: 'stable' + cache: + description: Whether the downloaded Solana release should be cached + required: true + default: 'true' + base_url: + description: The base URL to download the Solana release from — e.g. https://release.solana.com. + required: false + +runs: + using: 'composite' + steps: + - name: Cache Solana + id: cache + if: inputs.cache == 'true' + uses: actions/cache@v4 + with: + path: | + ~/.local/share/solana/install/releases/${{ inputs.version }} + ~/.cache/solana + key: ${{ runner.os }}-solana-v${{ inputs.version }} + + - name: Resolve Base URL + id: base_url + run: | + if [ "${{ inputs.base_url }}" != "" ]; then + echo "base_url='${{ inputs.base_url }}'" >> $GITHUB_OUTPUT + else + cutoff="1.18.19" + desired="${{ inputs.version }}" + if [ "$(printf '%s\n' "$cutoff" "$desired" | sort -V | head -n1)" = "$desired" ] && [ "$cutoff" != "$desired" ]; then + echo "base_url='https://release.solana.com'" >> $GITHUB_OUTPUT + else + echo "base_url='https://release.anza.xyz'" >> $GITHUB_OUTPUT + fi + fi + shell: bash + + - name: Install Solana + if: inputs.cache != 'true' || steps.cache.outputs.cache-hit != 'true' + run: | + sh -c "$(curl -sSfL ${{ steps.base_url.outputs.base_url }}/v${{ inputs.version }}/install)" + shell: bash + + - name: Set Active Solana Version + run: | + rm -f "$HOME/.local/share/solana/install/active_release" + ln -s "$HOME/.local/share/solana/install/releases/${{ inputs.version }}/solana-release" "$HOME/.local/share/solana/install/active_release" + shell: bash + + - name: Add Solana bin to Path + run: | + echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH + shell: bash + + - name: Verify Solana install + run: | + solana --version + shell: bash diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 28323e5..c835c13 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -56,7 +56,7 @@ runs: - name: Install Solana if: ${{ inputs.solana == 'true' }} - uses: metaplex-foundation/actions/install-solana@v1 + uses: ./.github/actions/install-solana with: version: ${{ env.SOLANA_VERSION }} cache: true