-
Notifications
You must be signed in to change notification settings - Fork 8
169 lines (141 loc) · 4.75 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
name: Build
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
submodules: 'true'
# With rustup's nice new toml format, we just need to run rustup show to install the toolchain
# https://github.com/actions-rs/toolchain/issues/126#issuecomment-782989659
- name: Setup Rust toolchain
run: rustup show
- name: Cache Rust Dependecies
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
enclave/target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Build
run: cargo build --release
- name: Upload integritee-collator
uses: actions/upload-artifact@v2
with:
name: integritee-collator-${{ github.sha }}
path: target/release/integritee-collator
fmt:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
submodules: 'true'
- name: Setup Rust toolchain
run: rustup show
- name: fmt check
# fail job on warnings with `-- --check`
run: cargo fmt --all -- --check
clippy:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
submodules: 'true'
- name: Setup Rust toolchain
run: rustup show
- name: clippy
# fail job on warnings with `-- -D warnings`
run: cargo clippy -- -D warnings
create-artifacts:
needs: build
runs-on: ubuntu-20.04
env:
CHAIN_SPEC: ${{ matrix.chain }}-${{ matrix.config }}
working-directory: ./
PARACHAIN_IMAGE_NAME: integritee/parachain
strategy:
fail-fast: false
matrix:
chain: [shell]
config: [kusama]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Prepare
id: prep
run: |
DOCKER_IMAGE=${{ env.PARACHAIN_IMAGE_NAME }}
VERSION=edge
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/v}
fi
if [ "${{ github.event_name }}" = "schedule" ]; then
VERSION=nightly
fi
TAGS="${DOCKER_IMAGE}:${VERSION}"
VERSION=${{ github.event.release.tag_name }}
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
TAGS="$TAGS,${DOCKER_IMAGE}:latest"
fi
echo ::set-output name=tags::${TAGS}
- uses: actions/download-artifact@v2
with:
name: integritee-collator-${{ github.sha }}
- name: 'Create binaries for artifacts'
# Note: there is no way to pass the parachain-id to the `build-spec` cmd, which which imposes to set
# `DEFAULT_PARA_ID=2015` in the `polkadot-parachains/command`.
run: |
chmod +x ./integritee-collator
./integritee-collator export-genesis-state --chain ${{ env.CHAIN_SPEC }} --parachain-id 2015 > ${{ env.CHAIN_SPEC }}.state
./integritee-collator build-spec --chain ${{ env.CHAIN_SPEC }} --disable-default-bootnode --raw > ${{ env.CHAIN_SPEC }}.json
- name: Compute file metadata
id: vars
run: |
sha256sum ${{ env.CHAIN_SPEC }}.state >> checksums.txt
sha256sum ${{ env.CHAIN_SPEC }}.json >> checksums.txt
- name: Upload ${{ env.CHAIN_SPEC }} Files
uses: actions/upload-artifact@v2
with:
name: ${{ env.CHAIN_SPEC }}-${{ github.sha }}
path: |
checksums.txt
${{ env.CHAIN_SPEC }}.state
${{ env.CHAIN_SPEC }}.json
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
with:
platforms: all
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
builder: ${{ steps.buildx.outputs.name }}
context: ${{env.working-directory}}
file: ${{env.working-directory}}/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.prep.outputs.tags }}