-
Notifications
You must be signed in to change notification settings - Fork 289
180 lines (153 loc) · 5.38 KB
/
docker-localnet.yml
File metadata and controls
180 lines (153 loc) · 5.38 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
name: Publish Localnet Docker Image
on:
release:
types: [published]
workflow_dispatch:
inputs:
branch-or-tag:
description: "The branch or tag to use as the Docker image tag (optional)."
required: false
default: ""
push:
branches:
- devnet-ready
- main
- testnet
- devnet
concurrency:
group: docker-localnet-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
packages: write
actions: read
security-events: write
jobs:
setup:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.vars.outputs.tag }}
ref: ${{ steps.vars.outputs.ref }}
latest_tag: ${{ steps.vars.outputs.latest_tag }}
steps:
- name: Determine Docker tag and ref
id: vars
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo "ref=${{ github.head_ref }}" >> $GITHUB_OUTPUT
echo "tag=${{ github.base_ref }}" >> $GITHUB_OUTPUT
else
tag="${{ github.event.inputs.branch-or-tag || github.ref_name }}"
echo "ref=${{ github.ref_name }}" >> $GITHUB_OUTPUT
echo "tag=$tag" >> $GITHUB_OUTPUT
fi
if [[ "$tag" != "devnet-ready" ]]; then
echo "latest_tag=true" >> $GITHUB_OUTPUT
else
echo "latest_tag=false" >> $GITHUB_OUTPUT
fi
# build artifacts for fast-runtime and non-fast-runtime
artifacts:
name: Node • ${{ matrix.runtime }} • ${{ matrix.platform.arch }}
needs: setup
strategy:
matrix:
platform:
# triple names used `in scripts/install_prebuilt_binaries.sh` file
- runner: [self-hosted, type-ccx33]
triple: x86_64-unknown-linux-gnu
arch: amd64
- runner: [ubuntu-24.04-arm]
triple: aarch64-unknown-linux-gnu
arch: arm64
runtime: ["fast-runtime", "non-fast-runtime"]
runs-on: ${{ matrix.platform.runner }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ needs.setup.outputs.ref }}
- name: Install Rust + dependencies
run: |
chmod +x ./scripts/install_build_env.sh
./scripts/install_build_env.sh
- name: Add Rust target triple
run: |
source "$HOME/.cargo/env"
rustup target add ${{ matrix.platform.triple }}
- name: Patch limits for local run
run: |
chmod +x ./scripts/localnet_patch.sh
./scripts/localnet_patch.sh
- name: Build binaries
run: |
export PATH="$HOME/.cargo/bin:$PATH"
export CARGO_BUILD_TARGET="${{ matrix.platform.triple }}"
if [ "${{ matrix.runtime }}" = "fast-runtime" ]; then
./scripts/localnet.sh --build-only
else
./scripts/localnet.sh False --build-only
fi
# use `ci_target` name bc .dockerignore excludes `target`
- name: Prepare artifacts for upload
run: |
RUNTIME="${{ matrix.runtime }}"
TRIPLE="${{ matrix.platform.triple }}"
mkdir -p build/ci_target/${RUNTIME}/${TRIPLE}/release/
cp -v target/${RUNTIME}/${TRIPLE}/release/node-subtensor \
build/ci_target/${RUNTIME}/${TRIPLE}/release/
mkdir -p build/ci_target/${RUNTIME}/${TRIPLE}/release/wbuild/node-subtensor-runtime/
cp -v target/${RUNTIME}/${TRIPLE}/release/wbuild/node-subtensor-runtime/node_subtensor_runtime.compact.compressed.wasm \
build/ci_target/${RUNTIME}/${TRIPLE}/release/wbuild/node-subtensor-runtime/
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: binaries-${{ matrix.platform.triple }}-${{ matrix.runtime }}
path: build/
if-no-files-found: error
# Collect all artifacts and publish them to docker repo
docker:
needs: [setup, artifacts]
runs-on: [self-hosted, type-ccx33]
defaults:
run:
working-directory: ${{ github.workspace }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ needs.setup.outputs.ref }}
- name: Download all binary artifacts
uses: actions/download-artifact@v5
with:
pattern: binaries-*
path: build/
merge-multiple: true
- name: Show current Git branch
run: |
echo "==============================="
echo "Current Git branch:"
git rev-parse --abbrev-ref HEAD
echo "==============================="
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile-localnet
build-args: |
BUILT_IN_CI="Boom shakalaka"
push: true
platforms: linux/amd64,linux/arm64
tags: |
ghcr.io/${{ github.repository }}-localnet:${{ needs.setup.outputs.tag }}
${{ needs.setup.outputs.latest_tag == 'true' && format('ghcr.io/{0}-localnet:latest', github.repository) || '' }}