diff --git a/README.md b/README.md new file mode 100644 index 0000000..5d2609e --- /dev/null +++ b/README.md @@ -0,0 +1,36 @@ +# Setup Anchor + +An optimized action for installing [Anchor](https://www.anchor-lang.com/). + +# Usage + +Here's an example workflow: + +```yaml +name: example-workflow +on: [push] +jobs: + run-anchor-build: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v3 + - uses: metadaoproject/setup-anchor@v1.1 + - run: anchor build + shell: bash +``` + +This will use the default versions of Anchor, Node.js, and the Solana CLI tools, which are 0.27.0, 16.15.1, and 1.15.2 respectively. You can also configure these versions like so: + +```yaml +steps: + - uses: actions/checkout@v3 + - uses: metadaoproject/setup-anchor@v1.1 + with: + anchor-version: '0.24.2' + solana-cli-version: '1.10.32' + node-version: '16.15.1' +``` + +# License + +The scripts and documentation in this project are released under the [MIT License](LICENSE). diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..2a85e19 --- /dev/null +++ b/action.yml @@ -0,0 +1,41 @@ +name: 'Setup Anchor' +description: 'Install Anchor, Solana CLI tools, and Node.js.' +branding: + icon: anchor + color: blue +inputs: + node-version: + description: 'Version of node.js to use' + required: false + default: '16.15.1' # LTS + solana-cli-version: + description: 'Version of Solana CLI to use' + required: false + default: '1.15.2' # stable + anchor-version: + description: 'Version of Anchor to use' + required: false + default: '0.27.0' # latest +runs: + using: 'composite' + steps: + - uses: actions/setup-node@v3 + with: + node-version: ${{ inputs.node-version }} + - name: Cache Solana CLI tools + uses: actions/cache@v3 + with: + path: | + ~/.cache/solana/ + ~/.local/share/solana/ + key: solana-cli-${{ runner.os }}-build-${{ inputs.solana-cli-version }} + - name: Install Solana CLI tools + run: sh -c "$(curl -sSfL https://release.solana.com/v${{ inputs.solana-cli-version }}/install)" + shell: bash + - name: Update PATH + run: echo "/home/runner/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH + shell: bash + - name: Install Anchor + run: npm i -g @project-serum/anchor-cli@${{ inputs.anchor-version }} + shell: bash +