66 workflow_dispatch :
77 inputs :
88 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). "
1010 required : false
1111 default : " "
1212 push :
1515 - main
1616 - testnet
1717 - devnet
18-
18+
1919concurrency :
2020 group : docker-localnet-${{ github.ref }}
2121 cancel-in-progress : true
@@ -27,29 +27,130 @@ permissions:
2727 security-events : write
2828
2929jobs :
30- publish :
31- runs-on : [self-hosted, type-ccx53, type-ccx43, type-ccx33]
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 }}
3336 steps :
3437 - 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
3691 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
92+ chmod +x ./scripts/localnet_patch.sh
93+ ./scripts/localnet_patch.sh
94+
95+ - name : Build binaries
96+ run : |
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
45102 else
46- echo "latest_tag=false" >> $GITHUB_ENV
103+ ./scripts/localnet.sh False --build-only
47104 fi
48105
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 :
49136 - name : Checkout code
50137 uses : actions/checkout@v4
51138 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
147+
148+ - name : Show current Git branch
149+ run : |
150+ echo "==============================="
151+ echo "Current Git branch:"
152+ git rev-parse --abbrev-ref HEAD
153+ echo "==============================="
53154
54155 - name : Set up QEMU
55156 uses : docker/setup-qemu-action@v3
@@ -64,18 +165,16 @@ jobs:
64165 username : ${{ github.actor }}
65166 password : ${{ secrets.GITHUB_TOKEN }}
66167
67- - name : Patch non-fast-block node
68- run : |
69- chmod +x ./scripts/localnet_patch.sh
70- ./scripts/localnet_patch.sh
71-
72168 - name : Build and push Docker image
73169 uses : docker/build-push-action@v6
74170 with :
75171 context : .
76172 file : Dockerfile-localnet
173+ build-args : |
174+ BUILT_IN_CI="Boom shakalaka"
175+
77176 push : true
78177 platforms : linux/amd64,linux/arm64
79178 tags : |
80- ghcr.io/${{ github.repository }}-localnet:${{ env .tag }}
81- ${{ env .latest_tag == 'true' && format('ghcr.io/{0}-localnet:latest', github.repository) || '' }}
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