-
Notifications
You must be signed in to change notification settings - Fork 92
92 lines (83 loc) · 3.28 KB
/
_build-aleph-node.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
---
# This workflow builds aleph-node binary and docker image.
# It outputs name of artifacts uploaded to GH Artifacts.
name: Build aleph-node
on:
workflow_call:
inputs:
ref:
description: 'git ref: hash, branch, tag to build aleph-node binary from'
type: string
required: true
production:
description: 'Set to true to build production binary, otherwise set to false'
type: boolean
required: true
outputs:
artifact-name-binary:
description: 'Name of artifact aleph-node binary'
value: ${{ jobs.main.outputs.artifact-name-binary }}
artifact-name-image:
description: 'Name of artifact aleph-node image'
value: ${{ jobs.main.outputs.artifact-name-image }}
jobs:
main:
name: Build aleph-node (production=${{ inputs.production }})
runs-on: [self-hosted, Linux, X64, large]
env:
RUST_BACKTRACE: full
RUSTC_WRAPPER: sccache
CARGO_FOLDER: ${{ inputs.production == true && 'production' || 'release' }}
ARTIFACT_NAME_SUFFIX: ${{ inputs.production == true && 'production' || 'test' }}
outputs:
artifact-name-binary: ${{ steps.get-artifact-name-binary.outputs.name }}
artifact-name-image: ${{ steps.get-artifact-name-image.outputs.name }}
steps:
- name: Checkout aleph-node source code
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
fetch-depth: 0
- name: Call action get-ref-properties
id: get-ref-properties
uses: Cardinal-Cryptography/github-actions/get-ref-properties@v7
- name: Install Rust toolchain
uses: Cardinal-Cryptography/github-actions/install-rust-toolchain@v7
- name: Build test aleph-node
if: ${{ inputs.production != true }}
run: |
cargo build --release -p aleph-node --features only_legacy
- name: Build production aleph-node
if: ${{ inputs.production == true }}
run: cargo build --profile production -p aleph-node
- name: Get binary artifact name
id: get-artifact-name-binary
run: |
echo "name=aleph-node-${{ env.ARTIFACT_NAME_SUFFIX }}" >> $GITHUB_OUTPUT
- name: Upload binary to GH Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ steps.get-artifact-name-binary.outputs.name }}
path: target/${{ env.CARGO_FOLDER }}/aleph-node
if-no-files-found: error
retention-days: 7
- name: Build aleph-node docker image
run: |
chmod +x target/${{ env.CARGO_FOLDER }}/aleph-node
if [[ ${{ inputs.production }} == true ]]; then
mkdir -p target/release
mv target/production/aleph-node target/release/
fi
docker build --tag aleph-node:latest -f ./docker/Dockerfile .
docker save -o aleph-node.tar aleph-node:latest
- name: Get image artifact name
id: get-artifact-name-image
run: |
echo "name=aleph-node-image-${{ env.ARTIFACT_NAME_SUFFIX }}" >> $GITHUB_OUTPUT
- name: Upload docker to GH Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ steps.get-artifact-name-image.outputs.name }}
path: aleph-node.tar
if-no-files-found: error
retention-days: 7