Skip to content

Commit

Permalink
v1
Browse files Browse the repository at this point in the history
  • Loading branch information
jpbogle committed Oct 14, 2022
0 parents commit 5811ae2
Show file tree
Hide file tree
Showing 5 changed files with 299 additions and 0 deletions.
99 changes: 99 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Dependency directory
node_modules

# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# OS metadata
.DS_Store
Thumbs.db

# Ignore built ts files
__tests__/runner/*
lib/**/*
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 GitHub Actions

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Solana Buffer Deploy Github Action

<p align="center">
<a href="https://github.com/actions/javascript-action/actions"><img alt="javscript-action status" src="https://github.com/actions/javascript-action/workflows/units-test/badge.svg"></a>
</p>

<div align="center">
<img src="./assets/banner.png" />
</div>

Use this github action to automate Solana program deployments straight from Github. Use in conjunction with https://github.com/cardinal-labs/squads-program-upgrade.

## Usage

You can now consume the action by referencing the v1 branch

```yaml
uses: actions/solana-buffer-deploy@v0.1.0
with:
network: https://api.devnet.solana.com
program: my_program
keypair: ${{ env.DEPLOYER_KEYPAIR }}
program-id: prgCo6HJ2bP8xPJ3zwVnfVbqhBbBgY8t7moykr7wzCx
buffer-authority: 7CLWzQ3pGwk9TCBnNFVq2p79NGQ8WyhSrrjfXiPN4L9m
```
## Package for distribution
GitHub Actions will run the entry point from the action.yml.
Packaging assembles the code into one file in the dist folder that can be checked in to Git, enabling fast and reliable execution and preventing the need to check in node_modules.
Run prepare
```bash
yarn prepare
```

Since the packaged index.js is run from the dist folder.

```bash
git add dist
```

See the [actions tab](https://github.com/actions/solana-buffer-deploy/actions) for runs of this action! :rocket:
134 changes: 134 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
name: 'Solana buffer deploy'
description: 'Github action to deploy a program buffer on Solana'
author: 'Cardinal Labs'
branding:
icon: 'upload'
color: 'red'
inputs:
network:
description: 'The Solana network'
required: true
default: 'devnet'
program:
description: 'The program to build and upload'
required: true
program-id:
description: 'The program id of the program we are uploading'
required: true
buffer-authority:
description: 'The buffer authority to set'
required: true
keypair:
description: 'The keypair to use for deploys'
required: true
outputs:
buffer:
description: 'The buffer address'
idl-buffer:
description: 'The idl buffer address.'
runs:
using: 'composite'
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/install-linux-build-deps
- uses: actions-rs/toolchain@v1
with:
override: true
profile: minimal
toolchain: ${{ env.RUST_TOOLCHAIN }}
- uses: ./.github/actions/install-solana
with:
solana_version: ${{ env.SOLANA_VERSION }}
- uses: ./.github/actions/install-anchor
with:
anchor_git: ${{ env.ANCHOR_GIT }}
anchor_version: ${{ env.ANCHOR_VERSION }}
- uses: actions/cache@v2
name: Cache Builds
id: cache-buffer
with:
path: |
./target
./buffer.out
./idl-buffer.out
key: ${{ inputs.network }}-${{ inputs.program-id }}-anchor-verified-build-${{ hashFiles('programs/**/*.rs') }}-${{ hashFiles('./**/Cargo.lock') }}
- run: ~/.cargo/bin/anchor build --verifiable -p $PROGRAM
shell: bash
# if: steps.cache-buffer.outputs.cache-hit != 'true'
env:
PROGRAM: ${{ inputs.program }}
- run: solana-keygen new -o keyp --no-bip39-passphrase
shell: bash
- run: echo KEYPAIR
shell: bash
env:
KEYPAIR: ${{ inputs.keypair }}
- run: echo "$KEYPAIR" > ./deploy-keypair.json && chmod 600 ./deploy-keypair.json
shell: bash
env:
KEYPAIR: ${{ inputs.keypair }}
- run: cat deploy-keypair.json
shell: bash
- name: Buffer Deploy
# if: steps.cache-buffer.outputs.cache-hit != 'true'
id: buffer-deploy
uses: nick-invision/retry@v2
with:
timeout_minutes: 30
max_attempts: 10
shell: bash
command: solana program write-buffer --buffer ./keyp -k ./deploy-keypair.json ./target/verifiable/$PROGRAM.so -u $NETWORK > ./buffer.out
env:
NETWORK: ${{ inputs.network }}
PROGRAM: ${{ inputs.program }}
- name: IDL Buffer Deploy
uses: nick-invision/retry@v2
id: idl-buffer-deploy
# if: steps.cache-buffer.outputs.cache-hit != 'true'
with:
timeout_minutes: 10
max_attempts: 50
shell: bash
command: ~/.cargo/bin/anchor idl write-buffer $PROGRAM_ID --filepath ./target/idl/$PROGRAM.json --provider.cluster $NETWORK --provider.wallet ./deploy-keypair.json > idl-buffer.out
env:
PROGRAM_ID: ${{ inputs.program-id }}
PROGRAM: ${{ inputs.program }}
NETWORK: ${{ inputs.network }}
- name: Buffer Deploy Store
shell: bash
id: buffer-deploy-store
run: |
echo "::set-output name=BUFFER::$(cat buffer.out | sed 's/Buffer: //g' | xargs echo -n)" &&
echo "::set-output name=IDL_BUFFER::$(cat idl-buffer.out | sed 's/Idl buffer created: //g' | xargs echo -n)"
- run: echo "The buffer is ${{ steps.buffer-deploy-store.outputs.BUFFER }}"
shell: bash
- run: echo "The IDL buffer is ${{ steps.buffer-deploy-store.outputs.IDL_BUFFER }}"
shell: bash
- name: Transfer idl buffer to authority
uses: nick-invision/retry@v2
# if: steps.cache-buffer.outputs.cache-hit != 'true'
with:
timeout_minutes: 10
max_attempts: 50
shell: bash
command: anchor idl set-authority $IDL_BUFFER --provider.cluster $NETWORK --program-id $PROGRAM_ID --new-authority $AUTHORITY --provider.wallet ./deploy-keypair.json
env:
IDL_BUFFER: ${{ steps.buffer-deploy-store.outputs.IDL_BUFFER }}
AUTHORITY: ${{ inputs.buffer-authority }}
NETWORK: ${{ inputs.network }}
PROGRAM_ID: ${{ inputs.program-id }}
- name: Transfer buffer to authority
uses: nick-invision/retry@v2
# if: steps.cache-buffer.outputs.cache-hit != 'true'
with:
timeout_minutes: 10
max_attempts: 50
shell: bash
command: solana program set-buffer-authority $BUFFER -k ./deploy-keypair.json --new-buffer-authority $AUTHORITY -u $NETWORK
env:
BUFFER: ${{ steps.buffer-deploy-store.outputs.BUFFER }}
AUTHORITY: ${{ inputs.buffer-authority }}
NETWORK: ${{ inputs.network }}
- run: rm ./deploy-keypair.json
shell: bash
if: always()
Binary file added assets/banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5811ae2

Please sign in to comment.