forked from paritytech/substrate-contracts-node
-
Notifications
You must be signed in to change notification settings - Fork 47
/
.gitlab-ci.yml
163 lines (148 loc) · 5.83 KB
/
.gitlab-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
# .gitlab-ci.yml
#
# substrate-contracts-node
#
# pipelines can be triggered manually in the web
default:
interruptible: true
retry:
max: 2
when:
- runner_system_failure
- unknown_failure
- api_failure
stages:
- fmt
- build-linux
- build-mac
- publish
variables:
GIT_STRATEGY: fetch
GIT_DEPTH: 100
CARGO_INCREMENTAL: 0
.collect-artifacts: &collect-artifacts
artifacts:
name: "${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}"
when: on_success
expire_in: 7 days
paths:
- artifacts/
.docker-env: &docker-env
image: paritytech/ci-linux:production
before_script:
- cargo -vV
- rustc -vV
- rustup show
- bash --version
tags:
- linux-docker-vm-c2
.kubernetes-env: &kubernetes-env
tags:
- kubernetes-parity-build
.build-refs: &build-refs
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
- if: $CI_COMMIT_REF_NAME == "main"
- if: $CI_COMMIT_REF_NAME == "tags"
- if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs
- if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1
.publish-refs: &publish-refs
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
- if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1
### stage: fmt
fmt:
stage: fmt
<<: *docker-env
script:
- cargo +nightly fmt --verbose --all -- --check
### stage: build-linux
build-linux:
stage: build-linux
<<: *docker-env
<<: *collect-artifacts
<<: *build-refs
script:
- time cargo build --release
- time cargo test --release --all
- mkdir -p ./artifacts/substrate-contracts-node-linux/
- cp target/release/substrate-contracts-node ./artifacts/substrate-contracts-node-linux/substrate-contracts-node
### stage: build-mac
build-mac:
stage: build-mac
<<: *docker-env
<<: *collect-artifacts
<<: *build-refs
before_script:
- unset CARGO_TARGET_DIR
script:
- time cargo build --release --target aarch64-apple-darwin
- rustup target add x86_64-apple-darwin
- time cargo build --release --target x86_64-apple-darwin
- 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'
tags:
- osx
publish:
stage: publish
<<: *kubernetes-env
image: paritytech/tools:latest
<<: *publish-refs
needs:
- job: build-linux
artifacts: true
- job: build-mac
artifacts: true
script:
- git describe --tags
- TAG_NAME=`git describe --tags`
- echo "tag name ${TAG_NAME}"
- tar -czvf ./substrate-contracts-node-linux.tar.gz ./artifacts/substrate-contracts-node-linux/substrate-contracts-node
- tar -czvf ./substrate-contracts-node-mac-universal.tar.gz ./artifacts/substrate-contracts-node-mac/substrate-contracts-node
- 'curl https://api.github.com/repos/paritytech/substrate-contracts-node/releases
--fail-with-body
-H "Cookie: logged_in=no"
-H "Authorization: token ${GITHUB_TOKEN}"'
- 'curl https://api.github.com/repos/paritytech/substrate-contracts-node/releases
--fail-with-body
-H "Cookie: logged_in=no"
-H "Authorization: token ${GITHUB_TOKEN}" | jq .'
- 'RELEASE_ID=$(curl https://api.github.com/repos/paritytech/substrate-contracts-node/releases
--fail-with-body
-H "Cookie: logged_in=no"
-H "Authorization: token ${GITHUB_TOKEN}"
| jq -r ".[] | select(.tag_name == \"$TAG_NAME\") | .id");
echo "release id if existent: ${RELEASE_ID}"'
- 'if [ -z "$RELEASE_ID" ]; then
RESP=$(curl -X "POST" "https://api.github.com/repos/paritytech/substrate-contracts-node/releases"
--fail-with-body
-H "Cookie: logged_in=no"
-H "Authorization: token ${GITHUB_TOKEN}"
-H "Content-Type: application/json; charset=utf-8"
-d $"{
\"tag_name\": \"${TAG_NAME}\",
\"name\": \"${TAG_NAME}\",
\"prerelease\": false,
\"draft\": true
}");
echo "api response ${RESP}";
RELEASE_ID=$(echo $RESP | jq -r .id);
echo "release id of created release ${RELEASE_ID}";
fi'
- echo "release id ${RELEASE_ID}"
- 'curl -X "POST" "https://uploads.github.com/repos/paritytech/substrate-contracts-node/releases/$RELEASE_ID/assets?name=substrate-contracts-node-linux.tar.gz"
--fail-with-body
-H "Cookie: logged_in=no"
-H "Authorization: token ${GITHUB_TOKEN}"
-H "Content-Type: application/octet-stream"
--data-binary @"./substrate-contracts-node-linux.tar.gz"'
- 'curl -X "POST" "https://uploads.github.com/repos/paritytech/substrate-contracts-node/releases/$RELEASE_ID/assets?name=substrate-contracts-node-mac-universal.tar.gz"
--fail-with-body
-H "Cookie: logged_in=no"
-H "Authorization: token ${GITHUB_TOKEN}"
-H "Content-Type: application/octet-stream"
--data-binary @"./substrate-contracts-node-mac-universal.tar.gz"'