-
Notifications
You must be signed in to change notification settings - Fork 51
159 lines (145 loc) · 5.84 KB
/
develop-release-program.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
name: Deploy Programs to devnet
env:
SOLANA_CLI_VERSION: 1.18.15
NODE_VERSION: 18.12.1
on:
push:
branches:
- develop
pull_request:
branches:
- develop
jobs:
detect_changed_programs:
if: github.event_name == 'push' || contains(github.event.pull_request.labels.*.name, 'deploy-to-devnet')
runs-on: ubuntu-latest
outputs:
programs_with_changes: ${{ steps.list_changed_programs.outputs.programs_with_changes }}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }}
- name: List changed programs
id: list_changed_programs
run: |
echo "Detecting changes in programs"
# Use git diff to get a list of changed programs and output it as JSON
changed_files=$(git diff --name-only ${{ (github.event_name == 'pull_request' && github.event.pull_request.base.sha) || github.event.before }} ${{ github.event.after }})
changed_programs=($(echo "$changed_files" | grep "^programs/" | grep -v "/shared-utils/" | cut -d '/' -f 2 | sort -u))
echo "${changed_programs[@]}"
json="[$(printf "'%s'", "${changed_programs[@]}" | sed 's/,$//')]"
echo $json
echo "programs_with_changes=$json" >> $GITHUB_OUTPUT
build_programs:
needs: [detect_changed_programs]
runs-on: ubuntu-latest
if: needs.detect_changed_programs.outputs.programs_with_changes != '[]' && needs.detect_changed_programs.outputs.programs_with_changes != ''
strategy:
matrix:
program: ${{ fromJson(needs.detect_changed_programs.outputs.programs_with_changes) }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set devnet lazy signer
run: |
find programs -type f -name '*.rs' -exec sed -i "s/b\"nJWGUMOK\"/b\"devnethelium5\"/g" {} \;
- uses: actions/cache@v2
name: Cache Toml Cli
id: cache-toml-cli
with:
path: |
~/.cargo/bin/toml
key: toml-cli-${{ runner.os }}-v0002
- run: (cargo install toml-cli || true)
if: steps.cache-toml-cli.outputs.cache-hit != 'true'
shell: bash
- name: Set program information
if: steps.cache-toml.outputs.cache-hit != 'true'
run: |
PROGRAM_NAME=${PROGRAM//-/_} # Substitute dashes with underscores
PROGRAM_ID=$(~/.cargo/bin/toml get Anchor.toml programs.localnet.${PROGRAM_NAME} | tr -d '"')
echo "Program: $PROGRAM_ID"
echo "PROGRAM_NAME=${PROGRAM_NAME}" >> $GITHUB_ENV
echo "PROGRAM_ID=${PROGRAM_ID}" >> $GITHUB_ENV
env:
PROGRAM: ${{ matrix.program }}
# Build the program with anchor so we get the IDL
- uses: ./.github/actions/build-anchor/
id: build-anchor
with:
testing: false
devnet: true
program: ${{ env.PROGRAM_NAME }}
- uses: ./.github/actions/build-verified/
id: build-verified
with:
devnet: true
program: ${{ env.PROGRAM_NAME }}
program-id: ${{ env.PROGRAM_ID }}
- name: Store so files
uses: actions/upload-artifact@v3
with:
name: ${{matrix.program}}-so
path: |
./target/deploy/${{env.PROGRAM_NAME}}.so
- name: Store idl files
uses: actions/upload-artifact@v3
with:
name: ${{matrix.program}}-idl
path: |
./target/idl/${{env.PROGRAM_NAME}}.json
publish_programs:
needs: [detect_changed_programs, build_programs]
runs-on: ubuntu-latest
if: needs.detect_changed_programs.outputs.programs_with_changes != '[]' && needs.detect_changed_programs.outputs.programs_with_changes != ''
strategy:
# Publish must happen one at a time or there can be conflicts
max-parallel: 1
matrix:
program: ${{ fromJson(needs.detect_changed_programs.outputs.programs_with_changes) }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- uses: ./.github/actions/setup-anchor/
- name: Set program information
if: steps.cache-toml.outputs.cache-hit != 'true'
run: |
PROGRAM_NAME=${PROGRAM//-/_} # Substitute dashes with underscores
PROGRAM_ID=$(~/.cargo/bin/toml get Anchor.toml programs.localnet.${PROGRAM_NAME} | tr -d '"')
echo "Program: $PROGRAM_ID"
echo "PROGRAM_NAME=${PROGRAM_NAME}" >> $GITHUB_ENV
echo "PROGRAM_ID=${PROGRAM_ID}" >> $GITHUB_ENV
env:
PROGRAM: ${{ matrix.program }}
- name: Download a so files
uses: actions/download-artifact@v3
with:
name: ${{matrix.program}}-so
path: ./target/deploy/
- name: Download idl files
uses: actions/download-artifact@v3
with:
name: ${{matrix.program}}-idl
path: ./target/idl/
- uses: ./.github/actions/buffer-deploy/
id: buffer-deploy
with:
devnet: true
network: ${{ secrets.DEVNET_SOLANA_DEPLOY_URL }}
program: ${{ env.PROGRAM_NAME }}
keypair: ${{ secrets.DEVNET_DEPLOYER_KEYPAIR }}
program-id: ${{ env.PROGRAM_ID }}
buffer-authority: ${{ secrets.DEVNET_MULTISIG_VAULT }}
- name: Squads program upgrade
uses: helium/[email protected]
with:
network-url: "https://api.devnet.solana.com"
program-multisig: ${{ secrets.DEVNET_MULTISIG }}
program-id: ${{ env.PROGRAM_ID }}
buffer: ${{ steps.buffer-deploy.outputs.buffer }}
idl-buffer: ${{ steps.buffer-deploy.outputs.idl-buffer }}
spill-address: ${{ secrets.DEVNET_DEPLOYER_ADDRESS }}
authority: ${{ secrets.DEVNET_MULTISIG_VAULT }}
name: "Deploy ${{ matrix.program }}"
keypair: ${{ secrets.DEVNET_DEPLOYER_KEYPAIR }}