-
Notifications
You must be signed in to change notification settings - Fork 5
138 lines (133 loc) · 5.39 KB
/
build.yml
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
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