|
| 1 | +name: Publish standalone regtest image |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + stacks_blockchain_commit: |
| 7 | + description: 'stacks-blockchain git commit' |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + |
| 11 | +env: |
| 12 | + STACKS_API_COMMIT: ${{ github.sha }} |
| 13 | + STACKS_BLOCKCHAIN_COMMIT: ${{ inputs.stacks_blockchain_commit }} |
| 14 | + |
| 15 | +jobs: |
| 16 | + build-stacks-node: |
| 17 | + runs-on: ubuntu-20.04 |
| 18 | + steps: |
| 19 | + - name: Checkout |
| 20 | + uses: actions/checkout@v3 |
| 21 | + - name: Cache stacks-node |
| 22 | + id: cache |
| 23 | + uses: actions/cache@v3 |
| 24 | + with: |
| 25 | + path: bin |
| 26 | + key: cache-stacks-node-${{ env.STACKS_BLOCKCHAIN_COMMIT }} |
| 27 | + - name: Install Rust - linux/amd64 |
| 28 | + if: steps.cache.outputs.cache-hit != 'true' |
| 29 | + uses: actions-rs/toolchain@v1 |
| 30 | + with: |
| 31 | + toolchain: stable |
| 32 | + target: x86_64-unknown-linux-gnu |
| 33 | + - name: Install Rust - linux/arm64 |
| 34 | + if: steps.cache.outputs.cache-hit != 'true' |
| 35 | + uses: actions-rs/toolchain@v1 |
| 36 | + with: |
| 37 | + toolchain: stable |
| 38 | + target: aarch64-unknown-linux-gnu |
| 39 | + - name: Install compilation tooling |
| 40 | + if: steps.cache.outputs.cache-hit != 'true' |
| 41 | + run: | |
| 42 | + sudo apt-get update |
| 43 | + sudo apt-get install -y g++-aarch64-linux-gnu libc6-dev-arm64-cross gcc-aarch64-linux-gnu |
| 44 | + - name: Fetch Stacks node repo |
| 45 | + if: steps.cache.outputs.cache-hit != 'true' |
| 46 | + run: | |
| 47 | + echo "$PWD" |
| 48 | + mkdir stacks-blockchain-repo && cd stacks-blockchain-repo |
| 49 | + git init |
| 50 | + git remote add origin https://github.com/stacks-network/stacks-blockchain.git |
| 51 | + git -c protocol.version=2 fetch --depth=1 origin $STACKS_BLOCKCHAIN_COMMIT |
| 52 | + git reset --hard FETCH_HEAD |
| 53 | + - name: Rust cache |
| 54 | + if: steps.cache.outputs.cache-hit != 'true' |
| 55 | + uses: Swatinem/rust-cache@v2 |
| 56 | + with: |
| 57 | + workspaces: "stacks-blockchain-repo" |
| 58 | + shared-key: rust-cache-stacks-node-${{ env.STACKS_BLOCKCHAIN_COMMIT }} |
| 59 | + - name: Cargo fetch |
| 60 | + if: steps.cache.outputs.cache-hit != 'true' |
| 61 | + working-directory: stacks-blockchain-repo |
| 62 | + run: | |
| 63 | + cargo fetch --manifest-path testnet/stacks-node/Cargo.toml --target x86_64-unknown-linux-gnu --target aarch64-unknown-linux-gnu |
| 64 | + - name: Build Stacks node |
| 65 | + if: steps.cache.outputs.cache-hit != 'true' |
| 66 | + working-directory: stacks-blockchain-repo |
| 67 | + env: |
| 68 | + CARGO_NET_GIT_FETCH_WITH_CLI: true |
| 69 | + CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc |
| 70 | + CC_aarch64_unknown_linux_gnu: aarch64-linux-gnu-gcc |
| 71 | + CXX_aarch64_unknown_linux_gnu: aarch64-linux-gnu-g++ |
| 72 | + AR_aarch64_unknown_linux_gnu: aarch64-linux-gnu-ar |
| 73 | + run: | |
| 74 | + cargo build --package stacks-node --bin stacks-node --release --target x86_64-unknown-linux-gnu --target aarch64-unknown-linux-gnu |
| 75 | + mkdir -p ../bin/x86_64-unknown-linux-gnu ../bin/aarch64-unknown-linux-gnu |
| 76 | + cp target/x86_64-unknown-linux-gnu/release/stacks-node ../bin/x86_64-unknown-linux-gnu |
| 77 | + cp target/aarch64-unknown-linux-gnu/release/stacks-node ../bin/aarch64-unknown-linux-gnu |
| 78 | + - uses: actions/upload-artifact@v3 |
| 79 | + with: |
| 80 | + name: stacks-node-bin |
| 81 | + if-no-files-found: error |
| 82 | + path: | |
| 83 | + bin/*/stacks-node |
| 84 | +
|
| 85 | + build-push-docker: |
| 86 | + needs: build-stacks-node |
| 87 | + runs-on: ubuntu-20.04 |
| 88 | + steps: |
| 89 | + - name: Checkout |
| 90 | + uses: actions/checkout@v3 |
| 91 | + - uses: actions/download-artifact@v3 |
| 92 | + with: |
| 93 | + name: stacks-node-bin |
| 94 | + path: docker/stacks-blockchain-binaries |
| 95 | + - name: Process of downloaded artifacts |
| 96 | + working-directory: docker/stacks-blockchain-binaries |
| 97 | + run: | |
| 98 | + ls -R |
| 99 | + chmod +x x86_64-unknown-linux-gnu/stacks-node |
| 100 | + chmod +x aarch64-unknown-linux-gnu/stacks-node |
| 101 | + - name: Create tag labels |
| 102 | + run: | |
| 103 | + api_short=$(head -c 7 <<< "$STACKS_API_COMMIT") |
| 104 | + blockchain_short=$(head -c 7 <<< "$STACKS_BLOCKCHAIN_COMMIT") |
| 105 | + echo "GIT_SHORTS=${api_short}-${blockchain_short}" >> $GITHUB_ENV |
| 106 | + - name: Docker meta |
| 107 | + id: meta |
| 108 | + uses: docker/metadata-action@v4 |
| 109 | + with: |
| 110 | + images: hirosystems/${{ github.event.repository.name }}-standalone-regtest |
| 111 | + tags: | |
| 112 | + type=raw,value=latest,enable=false |
| 113 | + type=raw,value={{date 'YYYYMMDDHH'}}-${{ env.GIT_SHORTS }} |
| 114 | + - name: Set up QEMU |
| 115 | + uses: docker/setup-qemu-action@v2 |
| 116 | + - name: Set up Docker Buildx |
| 117 | + uses: docker/setup-buildx-action@v2 |
| 118 | + with: |
| 119 | + config-inline: | |
| 120 | + [worker.oci] |
| 121 | + max-parallelism = 1 |
| 122 | + - name: Login to DockerHub |
| 123 | + uses: docker/login-action@v2 |
| 124 | + with: |
| 125 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 126 | + password: ${{ secrets.DOCKERHUB_PASSWORD }} |
| 127 | + - name: Build and push Docker image |
| 128 | + uses: docker/build-push-action@v3 |
| 129 | + with: |
| 130 | + file: docker/standalone-regtest.Dockerfile |
| 131 | + context: ./docker |
| 132 | + push: true |
| 133 | + platforms: linux/amd64,linux/arm64 |
| 134 | + tags: ${{ steps.meta.outputs.tags }} |
| 135 | + labels: ${{ steps.meta.outputs.labels }} |
| 136 | + cache-from: type=registry,ref=hirosystems/${{ github.event.repository.name }}-standalone-regtest |
| 137 | + cache-to: type=inline |
| 138 | + build-args: | |
| 139 | + STACKS_API_VERSION=${{ github.head_ref || github.ref_name }} |
| 140 | + API_GIT_COMMIT=${{ env.STACKS_API_COMMIT }} |
| 141 | + BLOCKCHAIN_GIT_COMMIT=${{ env.STACKS_BLOCKCHAIN_COMMIT }} |
0 commit comments