generated from stegaBOB/solana-program-template
-
Notifications
You must be signed in to change notification settings - Fork 29
163 lines (138 loc) · 4.71 KB
/
deploy-program.yml
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
160
161
162
163
name: Deploy Program
on:
workflow_dispatch:
inputs:
program:
description: Program
required: true
default: token-auth-rules
type: choice
options:
- token-auth-rules
cluster:
description: Cluster environment
required: true
default: devnet
type: choice
options:
- devnet
- mainnet-beta
publish_crate:
description: Release cargo crate
required: true
type: boolean
default: false
bump:
description: Version bump
required: true
default: patch
type: choice
options:
- patch
- minor
- major
env:
CACHE: true
jobs:
build_programs:
name: Programs
uses: ./.github/workflows/build-programs.yml
secrets: inherit
test_programs:
name: Programs
needs: build_programs
uses: ./.github/workflows/test-programs.yml
secrets: inherit
with:
program_matrix: '["${{ inputs.program }}"]'
test_js:
name: JS client
needs: test_programs
uses: ./.github/workflows/test-js.yml
secrets: inherit
deploy_program:
name: Program / Deploy
runs-on: ubuntu-latest-16-cores
needs: test_js
permissions:
contents: write
steps:
- name: Git checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.SVC_TOKEN }}
- name: Load environment variables
run: cat .github/.env >> $GITHUB_ENV
- name: Install Rust
uses: metaplex-foundation/actions/install-rust@v1
with:
toolchain: ${{ env.RUST_VERSION }}
- name: Install Solana
uses: metaplex-foundation/actions/install-solana@v1
with:
version: ${{ env.SOLANA_VERSION }}
cache: ${{ env.CACHE }}
- name: Install cargo-release
uses: metaplex-foundation/actions/install-cargo-release@v1
if: github.event.inputs.publish_crate == 'true'
with:
cache: ${{ env.CACHE }}
- name: Set RPC
run: |
if [ "${{ inputs.cluster }}" == "devnet" ]; then
echo RPC=${{ secrets.DEVNET_RPC }} >> $GITHUB_ENV
else
echo RPC=${{ secrets.MAINNET_RPC }} >> $GITHUB_ENV
fi
- name: Bump Program Version
run: |
IDL_NAME="mpl_`echo "${{ inputs.program }}" | tr - _`"
VERSION=`jq '.version' ./idls/${IDL_NAME}.json | sed 's/"//g'`
MAJOR=`echo ${VERSION} | cut -d. -f1`
MINOR=`echo ${VERSION} | cut -d. -f2`
PATCH=`echo ${VERSION} | cut -d. -f3`
if [ "${{ inputs.bump }}" == "major" ]; then
MAJOR=$((MAJOR + 1))
MINOR=0
PATCH=0
elif [ "${{ inputs.bump }}" == "minor" ]; then
MINOR=$((MINOR + 1))
PATCH=0
else
PATCH=$((PATCH + 1))
fi
PROGRAM_VERSION="${MAJOR}.${MINOR}.${PATCH}"
cp ./idls/${IDL_NAME}.json ./idls/${IDL_NAME}-previous.json
jq ".version = \"${PROGRAM_VERSION}\"" ./idls/${IDL_NAME}-previous.json > ./idls/${IDL_NAME}.json
rm ./idls/${IDL_NAME}-previous.json
echo PROGRAM_VERSION="${PROGRAM_VERSION}" >> $GITHUB_ENV
- name: Download program builds
uses: actions/download-artifact@v4
with:
name: program-builds
- name: Deploy Program
run: |
echo "Deploying ${{ inputs.program }} to ${{ inputs.cluster }}"
echo ${{ secrets.TOKEN_AUTH_RULES_DEPLOY_KEY }} > ./deploy-key.json
solana -v program deploy ./programs/.bin/mpl_token_auth_rules.so \
-u ${{ env.RPC }} \
--program-id auth9SigNpDKz4sJJ1DfCTuZrZNSAgh9sFD3rboVmgg \
-k ./deploy-key.json
rm ./deploy-key.json
- name: Publish crate
working-directory: ./programs/${{ inputs.program }}
if: github.event.inputs.publish_crate == 'true' && github.event.inputs.cluster == 'mainnet-beta'
run: |
git stash
git config user.name "${{ env.COMMIT_USER_NAME }}"
git config user.email "${{ env.COMMIT_USER_EMAIL }}"
cargo login ${{ secrets.CRATES_TOKEN }}
cargo release ${{ inputs.bump }} --no-confirm --no-push --no-tag --execute
git reset --soft HEAD~1
git stash pop
- name: Commit and tag new version
uses: stefanzweifel/git-auto-commit-action@v4
if: github.event.inputs.publish_crate == 'true' && github.event.inputs.cluster == 'mainnet-beta'
with:
commit_message: Deploy mpl-${{ inputs.program }} program v${{ env.PROGRAM_VERSION }}
tagging_message: mpl-${{ inputs.program }}@v${{ env.PROGRAM_VERSION }}