Skip to content

Commit da16663

Browse files
authored
fix: verified svm build in release (#999)
* fix: verified svm builds Signed-off-by: Reinis Martinsons <[email protected]> * fix: libudev-dev Signed-off-by: Reinis Martinsons <[email protected]> * fix: libudev Signed-off-by: Reinis Martinsons <[email protected]> * fix: libusb Signed-off-by: Reinis Martinsons <[email protected]> * fix: build dependencies Signed-off-by: Reinis Martinsons <[email protected]> * fix: build dependencies Signed-off-by: Reinis Martinsons <[email protected]> * fix: ignore-optional Signed-off-by: Reinis Martinsons <[email protected]> * fix: trigger ci Signed-off-by: Reinis Martinsons <[email protected]> * fix: trigger ci Signed-off-by: Reinis Martinsons <[email protected]> * fix: remove common tests Signed-off-by: Reinis Martinsons <[email protected]> * fix: remove only Signed-off-by: Reinis Martinsons <[email protected]> * fix: remove build-svm-verified Signed-off-by: Reinis Martinsons <[email protected]> * fix: build-verified script Signed-off-by: Reinis Martinsons <[email protected]> * fix: test-verified script Signed-off-by: Reinis Martinsons <[email protected]> * fix: rename scripts Signed-off-by: Reinis Martinsons <[email protected]> * fix: trigger ci Signed-off-by: Reinis Martinsons <[email protected]> * fix: use yaml anchor for matrix Signed-off-by: Reinis Martinsons <[email protected]> * fix: remove yaml anchor for matrix Signed-off-by: Reinis Martinsons <[email protected]> * fix: drop matrix Signed-off-by: Reinis Martinsons <[email protected]> * fix: use resolved node verion in cache keys Signed-off-by: Reinis Martinsons <[email protected]> * fix: verified build in release Signed-off-by: Reinis Martinsons <[email protected]> * fix: pre-release Signed-off-by: Reinis Martinsons <[email protected]> * fix: trigger ci Signed-off-by: Reinis Martinsons <[email protected]> * fix: trigger ci Signed-off-by: Reinis Martinsons <[email protected]> * fix: update publish workflow Signed-off-by: Reinis Martinsons <[email protected]> * fix: gh release svm binaries Signed-off-by: Reinis Martinsons <[email protected]> * fix: release tar.gz binaries Signed-off-by: Reinis Martinsons <[email protected]> * fix: paralel svm binary build in release Signed-off-by: Reinis Martinsons <[email protected]> * fix Signed-off-by: Reinis Martinsons <[email protected]> * fix Signed-off-by: Reinis Martinsons <[email protected]> * fix Signed-off-by: Reinis Martinsons <[email protected]> * fix: version Signed-off-by: Reinis Martinsons <[email protected]> * fix: version Signed-off-by: Reinis Martinsons <[email protected]> * fix: release verified test binaries Signed-off-by: Reinis Martinsons <[email protected]> * fix: prerelease Signed-off-by: Reinis Martinsons <[email protected]> * fix: reset version Signed-off-by: Reinis Martinsons <[email protected]> * fix: reset name Signed-off-by: Reinis Martinsons <[email protected]> --------- Signed-off-by: Reinis Martinsons <[email protected]>
1 parent 46f9741 commit da16663

File tree

7 files changed

+149
-23
lines changed

7 files changed

+149
-23
lines changed

.github/actions/cache-evm-artifacts/action.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,19 @@ outputs:
1111
runs:
1212
using: "composite"
1313
steps:
14+
- name: Resolve Node version
15+
id: resolved-node
16+
uses: ./.github/actions/setup-node-if-needed
17+
with:
18+
node_version: ${{ inputs.node_version }}
1419
- name: Restore cached EVM artifacts
1520
id: evm-artifacts-cache
1621
uses: actions/cache@v4
1722
with:
1823
# The job that generates the artifacts is responsible for archiving them to the cache tarball. This avoids any
1924
# conflicts with other caching actions that might have cleaned some of cached contents.
2025
path: evm-artifacts.tar
21-
key: evm-artifacts-${{ runner.os }}-node-${{ inputs.node_version }}-${{ hashFiles('yarn.lock', 'hardhat.config.ts', 'contracts/**/*.sol') }}
26+
key: evm-artifacts-${{ runner.os }}-node-${{ steps.resolved-node.outputs.version }}-${{ hashFiles('yarn.lock', 'hardhat.config.ts', 'contracts/**/*.sol') }}
2227
- name: Unpack restored EVM artifacts
2328
if: steps.evm-artifacts-cache.outputs.cache-hit == 'true'
2429
shell: bash

.github/actions/cache-svm-artifacts/action.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,19 @@ outputs:
1414
runs:
1515
using: "composite"
1616
steps:
17+
- name: Resolve Node version
18+
id: resolved-node
19+
uses: ./.github/actions/setup-node-if-needed
20+
with:
21+
node_version: ${{ inputs.node_version }}
1722
- name: Restore cached SVM artifacts
1823
id: svm-artifacts-cache
1924
uses: actions/cache@v4
2025
with:
2126
# The job that generates the artifacts is responsible for archiving them to the cache tarball. This avoids any
2227
# conflicts with other caching actions that might have cleaned some of cached contents.
2328
path: svm-${{ inputs.type }}.tar
24-
key: svm-${{ inputs.type }}-${{ runner.os }}-node-${{ inputs.node_version }}-${{ hashFiles('Cargo.lock', 'programs/**/Cargo.toml', 'programs/**/Xargo.toml', 'programs/**/*.rs') }}
29+
key: svm-${{ inputs.type }}-${{ runner.os }}-node-${{ steps.resolved-node.outputs.version }}-${{ hashFiles('Cargo.lock', 'programs/**/Cargo.toml', 'programs/**/Xargo.toml', 'programs/**/*.rs') }}
2530
- name: Unpack restored SVM artifacts
2631
if: steps.svm-artifacts-cache.outputs.cache-hit == 'true'
2732
shell: bash

.github/actions/generate-evm-artifacts/action.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ runs:
1010
using: "composite"
1111
steps:
1212
- name: "Use Node ${{ inputs.node_version }}"
13-
uses: actions/setup-node@v3
13+
uses: ./.github/actions/setup-node-if-needed
1414
with:
15-
node-version: "${{ inputs.node_version }}"
16-
cache: yarn
15+
node_version: ${{ inputs.node_version }}
1716
- name: Install packages
1817
shell: bash
1918
run: yarn install --frozen-lockfile

.github/actions/generate-svm-artifacts/action.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ runs:
1313
using: "composite"
1414
steps:
1515
- name: "Use Node ${{ inputs.node_version }}"
16-
uses: actions/setup-node@v3
16+
uses: ./.github/actions/setup-node-if-needed
1717
with:
18-
node-version: "${{ inputs.node_version }}"
19-
cache: yarn
18+
node_version: ${{ inputs.node_version }}
2019
- name: Setup Anchor & Solana
2120
uses: ./.github/actions/setup-solana-anchor
2221
with:
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Setup Node if needed
2+
description: "Set up Node.js if it is not already installed and resolve the version."
3+
inputs:
4+
node_version:
5+
description: "Node version to use"
6+
required: true
7+
outputs:
8+
version:
9+
description: "Resolved Node.js version"
10+
value: ${{ steps.resolved-node.outputs.version }}
11+
runs:
12+
using: "composite"
13+
steps:
14+
- name: Check if Node is installed
15+
id: check-node
16+
shell: bash
17+
run: |
18+
if command -v node >/dev/null 2>&1; then
19+
echo "installed=true" >> "$GITHUB_OUTPUT"
20+
else
21+
echo "installed=false" >> "$GITHUB_OUTPUT"
22+
fi
23+
- name: Setup Node.js
24+
if: steps.check-node.outputs.installed == 'false'
25+
uses: actions/setup-node@v3
26+
with:
27+
node-version: "${{ inputs.node_version }}"
28+
- name: Resolve actual Node version
29+
id: resolved-node
30+
shell: bash
31+
run: echo "version=$(node -v | sed 's/^v//')" >> "$GITHUB_OUTPUT"

.github/actions/setup-solana-anchor/action.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ inputs:
1010
runs:
1111
using: "composite"
1212
steps:
13+
- name: "Use Node ${{ inputs.node_version }}"
14+
uses: ./.github/actions/setup-node-if-needed
15+
with:
16+
node_version: ${{ inputs.node_version }}
1317
- name: Extract Solana versions
1418
uses: solana-developers/github-actions/[email protected]
1519
id: versions
@@ -19,4 +23,3 @@ runs:
1923
anchor_version: ${{ steps.versions.outputs.anchor_version }}
2024
solana_version: ${{ steps.versions.outputs.solana_version }}
2125
verify_version: ${{ inputs.verify_version }}
22-
node_version: ${{ inputs.node_version }}

.github/workflows/publish.yml

Lines changed: 98 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@ name: Publish Package to npmjs
1212
on:
1313
release:
1414
types: [created]
15+
env:
16+
NODE_VERSION: "20.x"
17+
EVM_ARTIFACTS_PATHS: |
18+
artifacts
19+
cache
20+
typechain
21+
SVM_ARTIFACTS_PATHS: |
22+
target/idl
23+
target/types
24+
src/svm/assets
25+
src/svm/clients
1526
jobs:
1627
build:
1728
runs-on: ubuntu-latest
@@ -22,26 +33,48 @@ jobs:
2233
- name: Validate and extract release information
2334
id: release
2435
uses: manovotny/[email protected]
25-
# Setup Anchor to enable compilation and export of Solana programs
26-
- name: Extract Solana versions
27-
uses: solana-developers/github-actions/[email protected]
28-
id: versions
29-
- name: Setup Anchor & Solana
30-
uses: solana-developers/github-actions/[email protected]
31-
with:
32-
anchor_version: ${{ steps.versions.outputs.anchor_version }}
33-
solana_version: ${{ steps.versions.outputs.solana_version }}
34-
node_version: 20
35-
# - run: anchor build
36+
3637
# Setup .npmrc file to publish to npm
3738
- uses: actions/setup-node@v3
3839
with:
39-
node-version: "20.x"
40+
node-version: "${{ env.NODE_VERSION }}"
4041
always-auth: true
4142
registry-url: "https://registry.npmjs.org"
43+
cache: "yarn"
44+
45+
- name: Install packages
46+
run: yarn install --frozen-lockfile
47+
48+
- name: Cache EVM artifacts
49+
id: evm-artifacts-cache
50+
uses: ./.github/actions/cache-evm-artifacts
51+
with:
52+
node_version: ${{ env.NODE_VERSION }}
53+
54+
- name: Generate EVM artifacts
55+
if: steps.evm-artifacts-cache.outputs.cache-hit != 'true'
56+
uses: ./.github/actions/generate-evm-artifacts
57+
with:
58+
path: ${{ env.EVM_ARTIFACTS_PATHS }}
59+
node_version: ${{ env.NODE_VERSION }}
60+
61+
- name: Cache SVM artifacts
62+
id: svm-artifacts-cache
63+
uses: ./.github/actions/cache-svm-artifacts
64+
with:
65+
type: artifacts
66+
node_version: ${{ env.NODE_VERSION }}
67+
68+
- name: Generate SVM artifacts
69+
if: steps.svm-artifacts-cache.outputs.cache-hit != 'true'
70+
uses: ./.github/actions/generate-svm-artifacts
71+
with:
72+
type: artifacts
73+
path: ${{ env.SVM_ARTIFACTS_PATHS }}
74+
node_version: ${{ env.NODE_VERSION }}
4275

43-
# Perform installs and run a build step.
44-
- run: yarn install --frozen-lockfile && yarn build
76+
- name: Build dist package
77+
run: yarn build-ts
4578

4679
# The last two steps will publish the package. Note that we're using
4780
# information from the `release` step above (I told you we'd use it
@@ -72,3 +105,54 @@ jobs:
72105
run: yarn publish --tag ${{ steps.release.outputs.tag }}
73106
env:
74107
NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
108+
109+
# Due to GitHub cache scoping, we cannot easily share the cache between releases even if the cache key is the same.
110+
# In order to not slow down the NPM package publishing, we move the building of SVM binaries for GitHub release to a
111+
# separate jobs that runs in parallel.
112+
release-svm-production:
113+
name: Release SVM production binaries on GitHub
114+
runs-on: ubuntu-latest
115+
steps:
116+
- uses: actions/checkout@v2
117+
118+
- name: Setup Anchor & Solana
119+
uses: ./.github/actions/setup-solana-anchor
120+
with:
121+
verify_version: 0.4.3
122+
node_version: ${{ env.NODE_VERSION }}
123+
124+
- name: Create verified production build
125+
run: yarn build-svm-solana-verify
126+
127+
- name: Archive verified production build
128+
run: tar -czf svm-verified-production-binaries.tar.gz target/deploy
129+
130+
- name: Release verified production binaries
131+
uses: softprops/action-gh-release@v2
132+
with:
133+
files: svm-verified-production-binaries.tar.gz
134+
135+
release-svm-test:
136+
name: Release SVM test binaries on GitHub
137+
runs-on: ubuntu-latest
138+
steps:
139+
- uses: actions/checkout@v2
140+
141+
- name: Setup Anchor & Solana
142+
uses: ./.github/actions/setup-solana-anchor
143+
with:
144+
verify_version: 0.4.3
145+
node_version: ${{ env.NODE_VERSION }}
146+
147+
- name: Create verified test build
148+
env:
149+
IS_TEST: true
150+
run: yarn build-svm-solana-verify
151+
152+
- name: Archive verified test build
153+
run: tar -czf svm-verified-test-binaries.tar.gz target/deploy
154+
155+
- name: Release verified test binaries
156+
uses: softprops/action-gh-release@v2
157+
with:
158+
files: svm-verified-test-binaries.tar.gz

0 commit comments

Comments
 (0)