forked from paritytech/substrate-contracts-node
-
Notifications
You must be signed in to change notification settings - Fork 0
168 lines (162 loc) · 6.12 KB
/
ci.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: CI
on:
push:
branches:
- main
tags:
- v*
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
# common variable is defined in the workflow
# repo env variable doesn't work for PR from forks
env:
CI_IMAGE: "paritytech/ci-unified:bullseye-1.81.0"
jobs:
set-image:
# This workaround sets the container image for each job using 'set-image' job output.
# env variables don't work for PR from forks, so we need to use outputs.
runs-on: ubuntu-latest
outputs:
CI_IMAGE: ${{ steps.set_image.outputs.CI_IMAGE }}
steps:
- id: set_image
run: echo "CI_IMAGE=${{ env.CI_IMAGE }}" >> $GITHUB_OUTPUT
fmt:
name: Cargo fmt
runs-on: ubuntu-latest
timeout-minutes: 5
needs: [set-image]
container:
image: ${{ needs.set-image.outputs.CI_IMAGE }}
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Rust Cache
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
with:
cache-on-failure: true
cache-all-crates: true
- name: cargo info
run: |
echo "######## rustup show ########"
rustup show
echo "######## cargo --version ########"
cargo --version
- name: Cargo fmt
run: cargo +nightly fmt --all -- --check
build-test-linux:
name: Build Linux
runs-on: ubuntu-latest
timeout-minutes: 50
needs: [set-image, fmt]
container:
image: ${{ needs.set-image.outputs.CI_IMAGE }}
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Rust Cache
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
with:
cache-on-failure: true
cache-all-crates: true
- name: cargo info
run: |
echo "######## rustup show ########"
rustup show
echo "######## cargo --version ########"
cargo --version
- name: Build and Test Linux
run: |
echo "######## cargo build ########"
cargo build --release
echo "######## cargo test ########"
cargo test --release --all
echo "######## Packing artifacts ########"
mkdir -p ./artifacts/substrate-contracts-node-linux/
cp target/release/substrate-contracts-node ./artifacts/substrate-contracts-node-linux/substrate-contracts-node
ls -la ./artifacts/substrate-contracts-node-linux/
- name: Upload artifacts
uses: actions/[email protected]
with:
name: build-linux
path: ./artifacts
build-macos:
timeout-minutes: 50
runs-on: macos-12
needs: [fmt]
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Set rust version from env file
run: |
echo $CI_IMAGE
RUST_VERSION=$(echo $CI_IMAGE | sed -E 's/.*ci-unified:([^-]+)-([^-]+).*/\2/')
echo $RUST_VERSION
echo "RUST_VERSION=${RUST_VERSION}" >> $GITHUB_ENV
- name: Set up Homebrew
uses: Homebrew/actions/setup-homebrew@1ccc07ccd54b6048295516a3eb89b192c35057dc # master from 12.09.2024
- name: Install protobuf
run: brew install protobuf
- name: Install rust ${{ env.RUST_VERSION }}
uses: actions-rust-lang/setup-rust-toolchain@1fbea72663f6d4c03efaab13560c8a24cfd2a7cc # v1.9.0
with:
cache: false
toolchain: ${{ env.RUST_VERSION }}
target: wasm32-unknown-unknown, aarch64-apple-darwin, x86_64-apple-darwin
components: cargo, clippy, rust-docs, rust-src, rustfmt, rustc, rust-std
- name: cargo info
run: |
echo "######## rustup show ########"
rustup show
echo "######## cargo --version ########"
cargo --version
- name: Rust Cache
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
with:
cache-on-failure: true
cache-all-crates: true
- name: Run cargo build
run: |
echo "######## cargo build aarch64-apple-darwin ########"
cargo build --release --target aarch64-apple-darwin
echo "######## cargo build x86_64-apple-darwin ########"
cargo build --release --target x86_64-apple-darwin
echo "######## Packing artifacts ########"
mkdir -p ./artifacts/substrate-contracts-node-mac/
lipo ./target/x86_64-apple-darwin/release/substrate-contracts-node \
./target/aarch64-apple-darwin/release/substrate-contracts-node \
-create -output ./artifacts/substrate-contracts-node-mac/substrate-contracts-node
ls -la ./artifacts/substrate-contracts-node-mac/
- name: Upload artifacts
uses: actions/[email protected]
with:
name: build-macos
path: ./artifacts
publish:
name: Publish release
runs-on: ubuntu-latest
needs: [build-test-linux, build-macos]
permissions:
contents: write
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: build-linux
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: build-macos
- name: Pack artifacts
run: |
tar -czvf ./substrate-contracts-node-linux.tar.gz ./substrate-contracts-node-linux
tar -czvf ./substrate-contracts-node-mac-universal.tar.gz ./substrate-contracts-node-mac
ls -la
- name: Publish release
uses: ghalactic/github-release-from-tag@cebdacac0ccd08933b8e7f278f4123723ad978eb # v5.4.0
if: github.ref_type == 'tag'
with:
prerelease: false
draft: true
assets: |
- path: substrate-contracts-node-linux.tar.gz
- path: substrate-contracts-node-mac-universal.tar.gz