Skip to content

Commit a50d830

Browse files
authored
Merge pull request #22 from hirosystems/ci/build-from-comittish
Ci/build from comittish
2 parents ecb1872 + 00a20b5 commit a50d830

File tree

2 files changed

+29
-11
lines changed

2 files changed

+29
-11
lines changed

.github/workflows/build.yml

+13-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
push:
55

66
env:
7-
STACKS_BLOCKCHAIN_COMMIT: ecfe80bf16cfe60ef6e68aa30e9b3f8d7b18e268
7+
STACKS_BLOCKCHAIN_COMMIT: "2.1.0.0.0"
88

99
jobs:
1010
cancel-previous-runs:
@@ -45,13 +45,21 @@ jobs:
4545
sudo apt-get install -y g++-aarch64-linux-gnu libc6-dev-arm64-cross gcc-aarch64-linux-gnu
4646
- name: Fetch Stacks node repo
4747
if: steps.cache.outputs.cache-hit != 'true'
48+
env:
49+
BLOCKCHAIN_REPO: https://github.com/stacks-network/stacks-blockchain.git
4850
run: |
4951
echo "$PWD"
5052
mkdir stacks-blockchain-repo && cd stacks-blockchain-repo
51-
git init
52-
git remote add origin https://github.com/stacks-network/stacks-blockchain.git
53-
git -c protocol.version=2 fetch --depth=1 origin $STACKS_BLOCKCHAIN_COMMIT
54-
git reset --hard FETCH_HEAD
53+
if git ls-remote -htq --exit-code $BLOCKCHAIN_REPO $STACKS_BLOCKCHAIN_COMMIT; then
54+
echo "Cloning Stacks blockchain from branch or tag: $STACKS_BLOCKCHAIN_COMMIT"
55+
git clone --depth 1 --branch "$STACKS_BLOCKCHAIN_COMMIT" "$BLOCKCHAIN_REPO" .
56+
else
57+
echo "Cloning Stacks blockchain from commit: $STACKS_BLOCKCHAIN_COMMIT"
58+
git init
59+
git remote add origin $BLOCKCHAIN_REPO
60+
git -c protocol.version=2 fetch --depth=1 origin $STACKS_BLOCKCHAIN_COMMIT
61+
git reset --hard FETCH_HEAD
62+
fi
5563
- name: Rust cache
5664
if: steps.cache.outputs.cache-hit != 'true'
5765
uses: Swatinem/rust-cache@v2

Dockerfile.e2e

+16-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
FROM rust:bullseye as builder
44

5-
ARG GIT_COMMIT=ecfe80bf16cfe60ef6e68aa30e9b3f8d7b18e268
5+
# A commit hash, tag, or branch
6+
ARG GIT_COMMIT=2.1.0.0.0
7+
ARG BLOCKCHAIN_REPO=https://github.com/stacks-network/stacks-blockchain.git
8+
69
ARG TARGETPLATFORM
710
ENV DEBIAN_FRONTEND noninteractive
811

@@ -23,11 +26,18 @@ RUN <<EOF
2326
mkdir -p target/release && mv "$STACKS_NODE_BIN_AMD64" target/release/stacks-node
2427
exit 0
2528
fi
26-
echo "Building stacks-node from commit: https://github.com/stacks-network/stacks-blockchain/commit/$GIT_COMMIT"
27-
git init
28-
git remote add origin https://github.com/stacks-network/stacks-blockchain.git
29-
git -c protocol.version=2 fetch --depth=1 origin "$GIT_COMMIT"
30-
git reset --hard FETCH_HEAD
29+
30+
if git ls-remote -htq --exit-code $BLOCKCHAIN_REPO $GIT_COMMIT; then
31+
echo "Cloning Stacks blockchain from branch or tag: $GIT_COMMIT"
32+
git clone --depth 1 --branch "$GIT_COMMIT" "$BLOCKCHAIN_REPO" .
33+
else
34+
echo "Cloning Stacks blockchain from commit: $GIT_COMMIT"
35+
git init
36+
git remote add origin $BLOCKCHAIN_REPO
37+
git -c protocol.version=2 fetch --depth=1 origin $GIT_COMMIT
38+
git reset --hard FETCH_HEAD
39+
fi
40+
3141
CARGO_NET_GIT_FETCH_WITH_CLI=true cargo build --package stacks-node --bin stacks-node --release
3242
EOF
3343

0 commit comments

Comments
 (0)