Skip to content

build for release

build for release #122

Workflow file for this run

name: build
on:
push:
env:
STACKS_BLOCKCHAIN_COMMIT: f8ffd1dbe8990234391def4611b2611be9a3e4ba
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-stacks-node:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cache stacks-node
id: cache
uses: actions/cache@v3
with:
path: bin
key: cache-stacks-node-${{ env.STACKS_BLOCKCHAIN_COMMIT }}
- name: Install Rust - linux/amd64
if: steps.cache.outputs.cache-hit != 'true'
run: rustup toolchain install stable
- name: Install Rust - linux/arm64
if: steps.cache.outputs.cache-hit != 'true'
run: rustup target add aarch64-unknown-linux-gnu
- name: Install compilation tooling
if: steps.cache.outputs.cache-hit != 'true'
run: |
sudo apt-get update
sudo apt-get install -y g++-aarch64-linux-gnu gcc-aarch64-linux-gnu libgcc-11-dev-arm64-cross
- name: Fetch Stacks node repo
if: steps.cache.outputs.cache-hit != 'true'
env:
BLOCKCHAIN_REPO: https://github.com/stacks-network/stacks-blockchain.git
run: |
echo "$PWD"
mkdir stacks-blockchain-repo && cd stacks-blockchain-repo
if git ls-remote -htq --exit-code $BLOCKCHAIN_REPO $STACKS_BLOCKCHAIN_COMMIT; then
echo "Cloning Stacks blockchain from branch or tag: $STACKS_BLOCKCHAIN_COMMIT"
git clone --depth 1 --branch "$STACKS_BLOCKCHAIN_COMMIT" "$BLOCKCHAIN_REPO" .
else
echo "Cloning Stacks blockchain from commit: $STACKS_BLOCKCHAIN_COMMIT"
git init
git remote add origin $BLOCKCHAIN_REPO
git -c protocol.version=2 fetch --depth=1 origin $STACKS_BLOCKCHAIN_COMMIT
git reset --hard FETCH_HEAD
fi
- name: Rust cache
if: steps.cache.outputs.cache-hit != 'true'
uses: Swatinem/rust-cache@v2
with:
workspaces: "stacks-blockchain-repo"
shared-key: rust-cache-stacks-node-${{ env.STACKS_BLOCKCHAIN_COMMIT }}
- name: Cargo fetch
if: steps.cache.outputs.cache-hit != 'true'
working-directory: stacks-blockchain-repo
run: |
cargo fetch --manifest-path testnet/stacks-node/Cargo.toml --target x86_64-unknown-linux-gnu --target aarch64-unknown-linux-gnu
- name: Build Stacks node
if: steps.cache.outputs.cache-hit != 'true'
working-directory: stacks-blockchain-repo
env:
CARGO_NET_GIT_FETCH_WITH_CLI: true
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
CC_aarch64_unknown_linux_gnu: aarch64-linux-gnu-gcc
CXX_aarch64_unknown_linux_gnu: aarch64-linux-gnu-g++
AR_aarch64_unknown_linux_gnu: aarch64-linux-gnu-ar
run: |
cargo build --package stacks-node --bin stacks-node --release --target x86_64-unknown-linux-gnu --target aarch64-unknown-linux-gnu
mkdir -p ../bin/x86_64-unknown-linux-gnu ../bin/aarch64-unknown-linux-gnu
cp target/x86_64-unknown-linux-gnu/release/stacks-node ../bin/x86_64-unknown-linux-gnu
cp target/aarch64-unknown-linux-gnu/release/stacks-node ../bin/aarch64-unknown-linux-gnu
- uses: actions/upload-artifact@v3
with:
name: stacks-node-bin
if-no-files-found: error
path: |
bin/*/stacks-node
build-push-docker:
needs: build-stacks-node
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: stacks-node-bin
path: stacks-blockchain-binaries
- name: Process of downloaded artifacts
working-directory: stacks-blockchain-binaries
run: |
ls -R
chmod +x x86_64-unknown-linux-gnu/stacks-node
chmod +x aarch64-unknown-linux-gnu/stacks-node
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: hirosystems/stacks-api-e2e
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=raw,value=stacks3.0,enable={{is_default_branch}}
type=raw,value=stacks3.0-{{branch}}-{{sha}}
type=ref,event=branch,prefix=stacks3.0-
type=ref,event=pr,prefix=stacks3.0-
type=semver,pattern={{version}},prefix=stacks3.0-
type=semver,pattern={{major}}.{{minor}},prefix=stacks3.0-
type=sha,prefix=stacks3.0-
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
config-inline: |
[worker.oci]
max-parallelism = 1
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN || secrets.DOCKERHUB_PASSWORD }}
- name: Build Docker images
uses: docker/build-push-action@v3
with:
file: Dockerfile.e2e
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=hirosystems/stacks-api-e2e:latest
cache-to: type=inline