Skip to content

Commit 602f47a

Browse files
committed
Update readme
1 parent 7968e3f commit 602f47a

File tree

2 files changed

+96
-151
lines changed

2 files changed

+96
-151
lines changed

.github/actions/build-verified/action.yaml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,9 @@
11
name: "Build Verified"
22
description: "Builds a Solana program using solana-verify"
33
inputs:
4-
devnet:
5-
description: "Whether to use devnet feature"
6-
required: false
7-
default: "false"
8-
testing:
9-
description: "Whether to use devnet feature"
10-
required: false
11-
default: "false"
124
program:
135
description: "The program to build and upload"
146
required: true
15-
program-id:
16-
description: "The program id of the program we are uploading"
17-
required: true
187
features:
198
description: "Features to enable during build"
209
required: false

readme.md

Lines changed: 96 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,30 @@
11
## GitHub Actions Usage
22

3-
This repository provides GitHub Actions for managing Solana program deployments and verification. The build action figures out the solana and anchor version and builds the program. If it is an anchor program it can also upload the IDL automatically. And it can also verify the program source code on chain.
3+
This repository provides GitHub Actions for managing Solana program deployments and verification.
4+
It is highly recommended to use the squads integration for program deployments.
5+
6+
### Features
7+
8+
- ✅ Automated program builds
9+
- ✅ Program verification against source code
10+
- ✅ IDL buffer creation and uploads
11+
- ✅ Squads multisig integration
12+
- ✅ Program deploys for both devnet and mainnet
13+
- ✅ Compute budget optimization
14+
- ✅ Retry mechanisms for RPC failures
415

516
### How to use
617

7-
Copy the .github folder and the scripts folder and the tsconfig.json (These are containing the squads SDK integration) into the root of your repository. After you commit these you will be able to use the actions from the github ui.
8-
The build at test flow will run the tests automatically every time the program changes.
9-
Then you can use the build action with all the options you need.
18+
The easiest way to use the github actions is using one of the [reusable workflows](https://github.com/solana-developers/github-workflows).
19+
20+
There are two examples:
21+
22+
- [Anchor Program](https://github.com/Woody4618/anchor-github-action-example)
23+
- [Native Program](https://github.com/Woody4618/native-solana-github-action-example)
1024

1125
### Required Secrets for specific actions
1226

13-
Some of the options of the build workflow require you to add secrets to your repository:
27+
Some of the actions of the build workflow require you to add secrets to your repository:
1428

1529
```bash
1630
# Network RPC URLs
@@ -21,131 +35,82 @@ MAINNET_SOLANA_DEPLOY_URL= # Your mainnet RPC URL - Recommended to use a payed
2135
DEVNET_DEPLOYER_KEYPAIR= # Base58 encoded keypair for devnet
2236
MAINNET_DEPLOYER_KEYPAIR= # Base58 encoded keypair for mainnet
2337

24-
PROGRAM_ADDRESS_KEYPAIR= # Keypair of the program address - Needed for initial deploy and for native programs to find the program address
38+
PROGRAM_ADDRESS_KEYPAIR= # Keypair of the program address - Needed for initial deploy and for native programs to find the program address. Can also be overwritten in the workflow if you dont have the keypair.
2539

2640
# For Squads integration
27-
DEVNET_MULTISIG= # Devnet Squads multisig address
28-
DEVNET_MULTISIG_VAULT= # Devnet Squads vault address
2941
MAINNET_MULTISIG= # Mainnet Squads multisig address
3042
MAINNET_MULTISIG_VAULT= # Mainnet Squads vault address
3143
```
3244

33-
### Extends and automate
34-
35-
You can easily extend or change your workflow. For example run the build workflow automatically on every push to a development branch.
36-
37-
```bash
38-
push:
39-
branches:
40-
- develop
41-
- dev
42-
- development
43-
paths:
44-
- 'programs/**'
45-
- 'Anchor.toml'
46-
- 'Cargo.toml'
47-
- 'Cargo.lock'
48-
```
49-
50-
Or run a new release to mainnet on every tag push for example.
51-
52-
```bash
53-
push:
54-
tags:
55-
- 'v*'
56-
```
57-
5845
Customize the workflow to your needs!
5946

60-
### Running the actions locally
61-
62-
If you for some reason want to run the actions locally you can do so with the following commands using the act command.
63-
64-
Follow the instructions [here](https://nektosact.com/installation/index.html) to install act.
65-
66-
1. Build
67-
68-
Just pick the parameters you want. This is using act to run the workflow locally. Good for testing or if you dont want to install anything because this is running in docker and outputs the build artifacts as well.
69-
70-
```bash
71-
act -W .github/workflows/build.yaml \
72-
--container-architecture linux/amd64 \
73-
--secret-file .secrets \
74-
workflow_dispatch \
75-
--input program=transaction-example \
76-
--input network=devnet \
77-
--input deploy=true \
78-
--input upload_idl=true \
79-
--input verify=true \
80-
--input use-squads=true
81-
```
82-
83-
2. Run anchor tests
84-
85-
Note: The anchor tests use solana-test-validator which does not work in act docker container on mac because of AVX dependency. Wither run them in github, locally without docker or open PR to fix it. I couldnt find a nice way to fix it.
86-
You can adjust the workflow to run your specific tests as well.
87-
88-
```bash
89-
act -W .github/workflows/test.yaml \
90-
--container-architecture linux/amd64 \
91-
--secret-file .secrets \
92-
workflow_dispatch \
93-
--input program=transaction-example
94-
```
95-
96-
### Features
97-
98-
- ✅ Automated program builds
99-
- ✅ Program verification against source code
100-
- ✅ IDL buffer creation and uploads
101-
- ✅ Squads multisig integration
102-
- ✅ Support for both devnet and mainnet
103-
- ✅ Compute budget optimization
104-
- ✅ Retry mechanisms for RPC failures
105-
106-
## How to setup Squads integration:
107-
108-
In general its recommended to use the [Squads Multisig](https://docs.squads.so/squads-cli/overview) to manage your programs.
109-
It makes your program deployments more secure and is considered good practice.
110-
111-
1. Setup a new squad in [Squads](https://v4.squads.so/squads/) then transfer your program authority to the squad.
112-
113-
2. Add your local keypair to the squad as a member (At least needs to be a voter) so that you can propose transactions. And also add that keypair as a github secret.
114-
To run it locally add the following to your .secrets file:
115-
116-
![alt text](image.png)
117-
118-
```bash
119-
DEVNET_DEPLOYER_KEYPAIR=
120-
MAINNET_DEPLOYER_KEYPAIR=
121-
```
122-
123-
2. Add the following to your .secrets file if you want to run it locally or add them to your github secrets if you want to run it in github actions:
124-
125-
```bash
126-
DEVNET_MULTISIG=
127-
DEVNET_MULTISIG_VAULT=
128-
MAINNET_MULTISIG=
129-
MAINNET_MULTISIG_VAULT=
130-
```
131-
132-
Where Multisig vault is the address you can find on the top left corner in the [Squads Dachboard](https://v4.squads.so/squads/)
133-
The MULTISIG is the address of the multisig you want to use this one you can find the the settings. Its a bit more hidden so that people dont accidentally use it as program upgrade authority.
134-
135-
What this will do is write a program and an IDL buffer for your program and then propose a transaction that you can approve in the Squads UI.
136-
137-
4. Now you can run the workflow with the following command:
138-
139-
```bash
140-
act -W .github/workflows/build.yaml \
141-
--container-architecture linux/amd64 \
142-
--secret-file .secrets \
143-
workflow_dispatch \
144-
--input program=transaction-example \
145-
--input network=devnet \
146-
--input deploy=true \
147-
--input upload_idl=true --input use-squads=true --input verify=true
148-
```
47+
## Key Actions
48+
49+
### Setup & Configuration
50+
51+
- `setup-all`: Comprehensive development environment setup
52+
53+
- Installs and configures Solana CLI tools
54+
- Sets up Anchor framework (if needed)
55+
- Installs solana-verify for build verification
56+
- Configures Node.js environment
57+
- Handles caching for faster subsequent runs
58+
- Inputs:
59+
- `solana_version`: Solana version to install
60+
- `anchor_version`: Anchor version to install
61+
- `verify_version`: solana-verify version to install
62+
- `node_version`: Node.js version to install
63+
64+
- `extract-versions`: Automatically detects required versions
65+
- Extracts Solana version from Cargo.lock
66+
- Detects Anchor version from Anchor.toml or Cargo.lock
67+
- Provides fallback versions if not found
68+
- Outputs:
69+
- `solana_version`: Detected Solana version
70+
- `anchor_version`: Detected Anchor version
71+
72+
### Build & Verification
73+
74+
- `build-verified`: Builds program with verification support
75+
- Uses solana-verify for reproducible builds
76+
- Supports both native and Anchor programs
77+
- Handles feature flags and conditional compilation
78+
- Inputs:
79+
- `program`: Program name to build
80+
- `features`: Optional Cargo features to enable
81+
82+
### Deployment
83+
84+
- `write-program-buffer`: Writes a buffer that will then later be set either from the provided keypair or from the squads multisig
85+
86+
- Creates buffer for program deployment
87+
- Set the buffer authority either to the provided keypair or to the squads multisig
88+
- Supports priority fees for faster transactions
89+
- Inputs:
90+
- `program-id`: Target program ID
91+
- `program`: Program name
92+
- `rpc-url`: Solana RPC endpoint
93+
- `keypair`: Deployer keypair
94+
- `buffer-authority-address`: Authority for the buffer
95+
- `priority-fee`: Transaction priority fee
96+
97+
- `write-idl-buffer`: Writes an Anchor IDL buffer that will then later be set either from the provided keypair or from the squads multisig
98+
- Creates IDL buffer
99+
- Sets up IDL authority
100+
- Prepares for IDL updates
101+
- Inputs:
102+
- `program-id`: Program ID
103+
- `program`: Program name
104+
- `rpc-url`: Solana RPC endpoint
105+
- `keypair`: Deployer keypair
106+
- `idl-authority`: Authority for IDL updates
107+
108+
### Additional Actions
109+
110+
- `build-anchor`: Specialized Anchor program builder
111+
- `program-upgrade`: Handles the exteding of the program account in case the program is getting bigger and either sets the buffer or skips that in case of squads deploy
112+
- `idl-upload`: Either sets the IDL buffer or skips that in case of squads deploy
113+
- `verify-build`: Verifies on-chain programs match source using solana-verify andthe osec api
149114

150115
## 📝 Todo List
151116

@@ -160,29 +125,31 @@ act -W .github/workflows/build.yaml \
160125
### Action Improvements
161126

162127
- [x] Separate IDL and Program buffer action
163-
- [ ] Remove deprecated cache functions
128+
- [x] Remove deprecated cache functions
164129
- [x] Remove node-version from anchor build
165-
- [ ] Support matrix build for develop branch
166-
- [ ] Skip anchor build when native program build
130+
- [x] Skip anchor build when native program build
167131
- [ ] Make verify build and anchor build in parallel
168132
- [x] Trigger release build on tag push
169133
- [x] Trigger devnet releases on develop branch?
170134
- [x] Make solana verify also work locally using cat
171135
- [x] Use keypairs to find deployer address to remove 2 secrets
172136
- [x] Add priority fees
173137
- [x] Add extend program if needed
174-
- [ ] Bundle the needed TS scripts with the .github actions for easier copy paste
138+
- [x] Bundle the needed TS scripts with the .github actions for easier copy paste
175139

176140
### Testing & Integration
177141

178142
- [x] Add running tests
179143
- Research support for different test frameworks
180144
- [ ] Add Codama support
181-
- [ ] Add to solana helpers -> release
145+
- [ ] Add to solana helpers or mucho -> release
146+
- [ ] Write guide and record video
182147

183-
Close Buffer:
148+
# Close Buffer in case of failure
184149

185-
You may need this in case your deploy failed and you want to close a buffer that was already transfered to your multisig.
150+
There may the occasions where the release flow fails in between writing the program buffer and the program deploy in squads.
151+
In that case you may want to close a buffer that was already transferred authority to your multisig.
152+
You can do that using the following command:
186153

187154
```bash
188155
solana program show --buffers --buffer-authority <You multisig vault address>
@@ -194,14 +161,3 @@ npx ts-node scripts/squad-closebuffer.ts \
194161
--keypair ~/.config/solana/id.json \
195162
--program "BhV84MZrRnEvtWLdWMRJGJr1GbusxfVMHAwc3pq92g4z"
196163
```
197-
198-
### Notes
199-
200-
- When using Squads, the workflow will create a proposal that needs to be approved in the Squads UI
201-
- For first deployments, program IDL authority errors can be ignored
202-
- If you run into any problems please open an issue and/or help fix it please :)
203-
204-
#### additional notes
205-
206-
- IDL must be upgraded before program upgrade instruction other wise it will fail
207-
- Buffer authority and program upgrade cannot be in the same transaction for some reason (at least using squads) thats why its set during the workflow and not in the squads scripts

0 commit comments

Comments
 (0)