Merge pull request #2215 from opentensor/testnet-into-devnet-ready #567
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) || '' }} |