Repository navigation
293 lines (262 loc) · 10.4 KB
/
Copy pathpublish-packages.yml
File metadata and controls
293 lines (262 loc) · 10.4 KB
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
name: Publish ephemeral validator packages and crates
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
release:
types: [published]
push:
branches:
- 'release/v*'
workflow_dispatch:
inputs:
release_version:
description: 'The release version'
required: true
default: 'v0.1.0'
jobs:
validate-release-branch:
name: Validate release branch
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- name: Checkout this magicblock-validator
uses: actions/checkout@v5
with:
path: magicblock-validator
- name: Check versions are aligned
shell: bash
run: |
cd magicblock-validator/.github && ./version-align.sh --check
publish-binaries:
name: Publish Binaries
if: github.event_name != 'push'
runs-on: ${{ matrix.build.OS }}
strategy:
fail-fast: false
matrix:
build:
- {
NAME: linux-x64-glibc,
OS: ubuntu-latest,
TOOLCHAIN: stable,
TARGET: x86_64-unknown-linux-gnu
}
- {
NAME: linux-arm64-glibc,
OS: arm64,
TOOLCHAIN: stable,
TARGET: aarch64-unknown-linux-gnu
}
- {
NAME: darwin-x64,
OS: macos-15-intel,
TOOLCHAIN: stable,
TARGET: x86_64-apple-darwin
}
- {
NAME: darwin-arm64,
OS: macos-latest,
TOOLCHAIN: stable,
TARGET: aarch64-apple-darwin
}
steps:
- name: Checkout this magicblock-validator
uses: actions/checkout@v5
with:
path: magicblock-validator
- uses: ./magicblock-validator/.github/actions/setup-build-env
with:
build_cache_key_name: "magicblock-validator-ci-publish-v000"
- name: Install target
shell: bash
run: rustup target add ${{ matrix.build.TARGET }}
- name: Set DRY_RUN by default
shell: bash
run: echo "DRY_RUN=true" >> $GITHUB_ENV
- name: Unset DRY_RUN for releases
if: github.event_name == 'release' && github.event.action == 'published'
shell: bash
run: echo "DRY_RUN=false" >> $GITHUB_ENV
- name: Set release version
shell: bash
run: |
if [ "${{ github.event_name }}" = "release" ]; then
echo "RELEASE_VERSION=${{ github.event.release.tag_name }}" >> $GITHUB_ENV
elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "RELEASE_VERSION=${{ github.event.inputs.release_version }}" >> $GITHUB_ENV
elif [[ "${{ github.ref }}" == refs/heads/release/v* ]]; then
echo "RELEASE_VERSION=$(echo ${{ github.ref }} | sed 's|refs/heads/release/||')" >> $GITHUB_ENV
else
echo "RELEASE_VERSION=v0.0.0-dev" >> $GITHUB_ENV
fi
- name: Set up GCC
if: matrix.build.OS == 'ubuntu-latest'
uses: egor-tensin/setup-gcc@v1.3
with:
version: latest
- name: Install additional build dependencies
if: startsWith(matrix.build.OS, 'ubuntu')
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y cmake pkg-config libssl-dev
- name: Install macOS dependencies
if: startsWith(matrix.build.OS, 'macos')
shell: bash
run: |
brew install protobuf llvm
# Add LLVM to PATH for libclang.dylib - base on target architecture
if [ "${{ matrix.build.TARGET }}" = "aarch64-apple-darwin" ]; then
echo "/opt/homebrew/opt/llvm/bin" >> $GITHUB_PATH
echo "LIBCLANG_PATH=/opt/homebrew/opt/llvm/lib" >> $GITHUB_ENV
else
echo "/usr/local/opt/llvm/bin" >> $GITHUB_PATH
echo "LIBCLANG_PATH=/usr/local/opt/llvm/lib" >> $GITHUB_ENV
fi
- name: Set macOS minimum version
if: startsWith(matrix.build.OS, 'macos')
shell: bash
run: |
echo "MACOSX_DEPLOYMENT_TARGET=11.0" >> $GITHUB_ENV
echo "CFLAGS=-mmacosx-version-min=11.0" >> $GITHUB_ENV
echo "CXXFLAGS=-mmacosx-version-min=11.0" >> $GITHUB_ENV
echo "LDFLAGS=-mmacosx-version-min=11.0" >> $GITHUB_ENV
- name: Force vendored OpenSSL for macOS
if: startsWith(matrix.build.OS, 'macos')
shell: bash
run: |
echo "OPENSSL_STATIC=1" >> $GITHUB_ENV
echo "OPENSSL_VENDORED=1" >> $GITHUB_ENV
- name: Build (linux/macos)
shell: bash
run: cargo build --manifest-path=magicblock-validator/Cargo.toml --release --locked --target ${{ matrix.build.TARGET }} -p magicblock-validator -p magicblock-verifier -p magicblock -p magicblock-validator-tui
- name: Check versions are aligned
shell: bash
run: |
cd magicblock-validator/.github && ./version-align.sh --check
- name: Build the NPM package
shell: bash
run: |
cd magicblock-validator
bin="ephemeral-validator"
node_os=$(echo "${{ matrix.build.NAME }}" | cut -d '-' -f1)
export node_os
node_arch=$(echo "${{ matrix.build.NAME }}" | cut -d '-' -f2)
export node_arch
export node_version="${{ env.RELEASE_VERSION }}"
export node_pkg="${bin}-${node_os}-${node_arch}"
echo "node_pkg=${node_pkg}" >> $GITHUB_ENV
mkdir -p "${node_pkg}/bin"
envsubst < .github/packages/npm-package/package.json.tmpl > "${node_pkg}/package.json"
cat "${node_pkg}/package.json"
echo "bin_name=${bin}" >> $GITHUB_ENV
cp "target/${{ matrix.build.TARGET }}/release/magicblock-validator" "${node_pkg}/bin/${bin}"
for artifact in magicblock-validator magicblock-verifier magicblock magicblock-validator-tui; do
cp \
"target/${{ matrix.build.TARGET }}/release/${artifact}" \
"target/${{ matrix.build.TARGET }}/release/${artifact}-${{ matrix.build.NAME }}"
done
- name: Publish magicblock-validator to GitHub release
if: ${{ env.DRY_RUN == 'false' }}
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: magicblock-validator/target/${{ matrix.build.TARGET }}/release/magicblock-validator-${{ matrix.build.NAME }}
overwrite: true
tag: "${{ env.RELEASE_VERSION }}"
release_name: "${{ env.RELEASE_VERSION }}"
asset_name: "magicblock-validator-${{ matrix.build.NAME }}"
- name: Publish magicblock-verifier to GitHub release
if: ${{ env.DRY_RUN == 'false' }}
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: magicblock-validator/target/${{ matrix.build.TARGET }}/release/magicblock-verifier-${{ matrix.build.NAME }}
overwrite: true
tag: "${{ env.RELEASE_VERSION }}"
release_name: "${{ env.RELEASE_VERSION }}"
asset_name: "magicblock-verifier-${{ matrix.build.NAME }}"
- name: Publish magicblock to GitHub release
if: ${{ env.DRY_RUN == 'false' }}
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: magicblock-validator/target/${{ matrix.build.TARGET }}/release/magicblock-${{ matrix.build.NAME }}
overwrite: true
tag: "${{ env.RELEASE_VERSION }}"
release_name: "${{ env.RELEASE_VERSION }}"
asset_name: "magicblock-${{ matrix.build.NAME }}"
- name: Publish magicblock-validator-tui to GitHub release
if: ${{ env.DRY_RUN == 'false' }}
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: magicblock-validator/target/${{ matrix.build.TARGET }}/release/magicblock-validator-tui-${{ matrix.build.NAME }}
overwrite: true
tag: "${{ env.RELEASE_VERSION }}"
release_name: "${{ env.RELEASE_VERSION }}"
asset_name: "magicblock-validator-tui-${{ matrix.build.NAME }}"
- name: Publish the NPM package
shell: bash
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
cd magicblock-validator
echo "DRY_RUN=${{ env.DRY_RUN }}"
cd ${{ env.node_pkg }}
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
npm set //registry.npmjs.org/:_authToken ${{ secrets.NPM_TOKEN }}
if [ "${{ env.DRY_RUN }}" = "true" ]; then
echo "Running npm publish in dry-run mode"
npm publish --access public --dry-run
else
npm publish --access public
fi
publish-wrapper-npm-package:
name: Publish wrapper NPM packages
if: github.event_name != 'push'
runs-on: ubuntu-latest
needs: publish-binaries
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Set DRY_RUN by default
shell: bash
run: echo "DRY_RUN=true" >> $GITHUB_ENV
- name: Unset DRY_RUN for releases
if: github.event_name == 'release' && github.event.action == 'published'
shell: bash
run: echo "DRY_RUN=false" >> $GITHUB_ENV
- uses: ./.github/actions/setup-solana
- name: Publish the NPM package
shell: bash
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
cd .github/packages/npm-package
npm install
npm run build
cd lib
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
npm set //registry.npmjs.org/:_authToken ${{ secrets.NPM_TOKEN }}
if [ "${{ env.DRY_RUN }}" = "true" ]; then
echo "Running npm publish in dry-run mode"
npm publish --access public --dry-run
else
npm publish --access public
fi
- name: cargo publish
working-directory: programs/magic-interface/
run: |
DRY_RUN_FLAG=""
if [ "${DRY_RUN}" = "true" ]; then
DRY_RUN_FLAG="--dry-run"
fi
if [ "${DRY_RUN}" = "true" ]; then
NO_VERIFY_FLAG="--no-verify"
fi
cargo publish $DRY_RUN_FLAG --manifest-path=./Cargo.toml --token $CRATES_TOKEN $NO_VERIFY_FLAG
env:
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}
DRY_RUN: ${{ env.DRY_RUN }}