6
6
workflow_dispatch :
7
7
inputs :
8
8
branch-or-tag :
9
- description : " Branch or tag to use for the Docker image tag and ref to checkout (optional)"
9
+ description : " The branch or tag to use as the Docker image tag (optional). "
10
10
required : false
11
11
default : " "
12
12
push :
15
15
- main
16
16
- testnet
17
17
- devnet
18
-
18
+
19
19
concurrency :
20
20
group : docker-localnet-${{ github.ref }}
21
21
cancel-in-progress : true
@@ -27,29 +27,123 @@ permissions:
27
27
security-events : write
28
28
29
29
jobs :
30
- publish :
31
- runs-on : SubtensorCI
32
-
30
+ setup :
31
+ runs-on : ubuntu-latest
32
+ outputs :
33
+ tag : ${{ steps.vars.outputs.tag }}
34
+ ref : ${{ steps.vars.outputs.ref }}
35
+ latest_tag : ${{ steps.vars.outputs.latest_tag }}
33
36
steps :
34
37
- name : Determine Docker tag and ref
35
- id : tag
38
+ id : vars
39
+ run : |
40
+ if [[ "${{ github.event_name }}" == "pull_request" ]]; then
41
+ echo "ref=${{ github.head_ref }}" >> $GITHUB_OUTPUT
42
+ echo "tag=${{ github.base_ref }}" >> $GITHUB_OUTPUT
43
+ else
44
+ tag="${{ github.event.inputs.branch-or-tag || github.ref_name }}"
45
+ echo "ref=${{ github.ref_name }}" >> $GITHUB_OUTPUT
46
+ echo "tag=$tag" >> $GITHUB_OUTPUT
47
+ fi
48
+
49
+ if [[ "$tag" != "devnet-ready" ]]; then
50
+ echo "latest_tag=true" >> $GITHUB_OUTPUT
51
+ else
52
+ echo "latest_tag=false" >> $GITHUB_OUTPUT
53
+ fi
54
+
55
+ # build artifacts for fast-runtime and non-fast-runtime
56
+ artifacts :
57
+ name : Node • ${{ matrix.runtime }} • ${{ matrix.platform.arch }}
58
+ needs : setup
59
+ strategy :
60
+ matrix :
61
+ platform :
62
+ # triple names used `in scripts/install_prebuilt_binaries.sh` file
63
+ - runner : [self-hosted, type-ccx33]
64
+ triple : x86_64-unknown-linux-gnu
65
+ arch : amd64
66
+ - runner : [ubuntu-24.04-arm]
67
+ triple : aarch64-unknown-linux-gnu
68
+ arch : arm64
69
+
70
+ runtime : ["fast-runtime", "non-fast-runtime"]
71
+
72
+ runs-on : ${{ matrix.platform.runner }}
73
+
74
+ steps :
75
+ - name : Checkout code
76
+ uses : actions/checkout@v4
77
+ with :
78
+ ref : ${{ needs.setup.outputs.ref }}
79
+
80
+ - name : Install Rust + dependencies
81
+ run : |
82
+ chmod +x ./scripts/install_build_env.sh
83
+ ./scripts/install_build_env.sh
84
+
85
+ - name : Add Rust target triple
86
+ run : |
87
+ source "$HOME/.cargo/env"
88
+ rustup target add ${{ matrix.platform.triple }}
89
+
90
+ - name : Patch limits for local run
91
+ run : |
92
+ chmod +x ./scripts/localnet_patch.sh
93
+ ./scripts/localnet_patch.sh
94
+
95
+ - name : Build binaries
36
96
run : |
37
- branch_or_tag="${{ github.event.inputs.branch-or-tag || github.ref_name }}"
38
- echo "Determined branch or tag: $branch_or_tag"
39
- echo "tag=$branch_or_tag" >> $GITHUB_ENV
40
- echo "ref=$branch_or_tag" >> $GITHUB_ENV
41
-
42
- # Check if this is a tagged release (not devnet-ready/devnet/testnet)
43
- if [[ "$branch_or_tag" != "devnet-ready" ]]; then
44
- echo "latest_tag=true" >> $GITHUB_ENV
97
+ export PATH="$HOME/.cargo/bin:$PATH"
98
+ export CARGO_BUILD_TARGET="${{ matrix.platform.triple }}"
99
+
100
+ if [ "${{ matrix.runtime }}" = "fast-runtime" ]; then
101
+ ./scripts/localnet.sh --build-only
45
102
else
46
- echo "latest_tag=false" >> $GITHUB_ENV
103
+ ./scripts/localnet.sh False --build-only
47
104
fi
48
105
106
+ # use `ci_target` name bc .dockerignore excludes `target`
107
+ - name : Prepare artifacts for upload
108
+ run : |
109
+ RUNTIME="${{ matrix.runtime }}"
110
+ TRIPLE="${{ matrix.platform.triple }}"
111
+
112
+ mkdir -p build/ci_target/${RUNTIME}/${TRIPLE}/release/
113
+ cp -v target/${RUNTIME}/${TRIPLE}/release/node-subtensor \
114
+ build/ci_target/${RUNTIME}/${TRIPLE}/release/
115
+
116
+ mkdir -p build/ci_target/${RUNTIME}/${TRIPLE}/release/wbuild/node-subtensor-runtime/
117
+ cp -v target/${RUNTIME}/${TRIPLE}/release/wbuild/node-subtensor-runtime/node_subtensor_runtime.compact.compressed.wasm \
118
+ build/ci_target/${RUNTIME}/${TRIPLE}/release/wbuild/node-subtensor-runtime/
119
+
120
+ - name : Upload artifact
121
+ uses : actions/upload-artifact@v4
122
+ with :
123
+ name : binaries-${{ matrix.platform.triple }}-${{ matrix.runtime }}
124
+ path : build/
125
+ if-no-files-found : error
126
+
127
+ # Collect all artifacts and publish them to docker repo
128
+ docker :
129
+ needs : [setup, artifacts]
130
+ runs-on : [self-hosted, type-ccx33]
131
+ defaults :
132
+ run :
133
+ working-directory : ${{ github.workspace }}
134
+
135
+ steps :
49
136
- name : Checkout code
50
137
uses : actions/checkout@v4
51
138
with :
52
- ref : ${{ env.ref }}
139
+ ref : ${{ needs.setup.outputs.ref }}
140
+
141
+ - name : Download all binary artifacts
142
+ uses : actions/download-artifact@v5
143
+ with :
144
+ pattern : binaries-*
145
+ path : build/
146
+ merge-multiple : true
53
147
54
148
- name : Show current Git branch
55
149
run : |
@@ -71,20 +165,16 @@ jobs:
71
165
username : ${{ github.actor }}
72
166
password : ${{ secrets.GITHUB_TOKEN }}
73
167
74
- - name : Patch non-fast-block node
75
- run : |
76
- chmod +x ./scripts/localnet_patch.sh
77
- ./scripts/localnet_patch.sh
78
-
79
168
- name : Build and push Docker image
80
169
uses : docker/build-push-action@v6
81
170
with :
82
171
context : .
83
172
file : Dockerfile-localnet
173
+ build-args : |
174
+ BUILT_IN_CI="Boom shakalaka"
175
+
84
176
push : true
85
177
platforms : linux/amd64,linux/arm64
86
178
tags : |
87
- ghcr.io/${{ github.repository }}-localnet:${{ env.tag }}
88
- ${{ env.latest_tag == 'true' && format('ghcr.io/{0}-localnet:latest', github.repository) || '' }}
89
- cache-from : type=gha
90
- cache-to : type=gha,mode=max
179
+ ghcr.io/${{ github.repository }}-localnet:${{ needs.setup.outputs.tag }}
180
+ ${{ needs.setup.outputs.latest_tag == 'true' && format('ghcr.io/{0}-localnet:latest', github.repository) || '' }}
0 commit comments