Newer
Older
#
# pipelines can be triggered manually in the web
stages:
- build-linux
- build-mac
- publish
CARGO_TARGET_DIR: "/ci-cache/${CI_PROJECT_NAME}/targets/${CI_COMMIT_REF_NAME}/${CI_JOB_NAME}"
workflow:
rules:
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH
.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
before_script:
- cargo -vV
- rustc -vV
- rustup show
- bash --version
- mkdir -p ${CARGO_TARGET_DIR}
- sccache -s
interruptible: true
retry:
max: 2
when:
- runner_system_failure
- unknown_failure
- api_failure
tags:
- linux-docker
.kubernetes-env: &kubernetes-env
retry:
max: 2
when:
- runner_system_failure
- unknown_failure
- api_failure
interruptible: true
tags:
- kubernetes-parity-build
.build-refs: &build-refs
rules:
- if: $CI_PIPELINE_SOURCE == "web"
- if: $CI_PIPELINE_SOURCE == "schedule"
- if: $CI_COMMIT_REF_NAME == "master"
- 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 == "web"
- if: $CI_PIPELINE_SOURCE == "schedule"
- if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1
### stage: build-linux
build-linux:
stage: build-linux
<<: *collect-artifacts
<<: *build-refs
- time cargo build --release
- time cargo test --release --all
- mkdir -p ./artifacts/canvas-linux/
- cp ${CARGO_TARGET_DIR}/release/canvas ./artifacts/canvas-linux/canvas
### stage: build-mac
build-mac:
stage: build-mac
# we run the mac build only when we actually want to publish
<<: *publish-refs
before_script:
- unset CARGO_TARGET_DIR
script:
- time cargo build --release
- mkdir -p ./artifacts/canvas-mac/
- cp target/release/canvas ./artifacts/canvas-mac/canvas
tags:
- osx
publish:
stage: publish
<<: *kubernetes-env
image: paritytech/tools:latest
<<: *publish-refs
needs:
- job: build-linux
artifacts: true
- job: build-mac
artifacts: true
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
- git describe --tags
- TAG_NAME=`git describe --tags`
- echo "tag name ${TAG_NAME}"
- tar -czvf ./canvas-linux.tar.gz ./artifacts/canvas-linux/canvas
- tar -czvf ./canvas-mac.tar.gz ./artifacts/canvas-mac/canvas
- |
RESP=$(curl -X "POST" "https://api.github.com/repos/paritytech/canvas-node/releases" \
-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\": true
}")
- echo "api response ${RESP}"
- RELEASE_ID=$(echo $RESP | jq -r .id)
- echo "release id ${RELEASE_ID}"
- |
curl -X "POST" "https://uploads.github.com/repos/paritytech/canvas-node/releases/$RELEASE_ID/assets?name=canvas-linux.tar.gz" \
-H "Cookie: logged_in=no" \
-H "Authorization: token ${GITHUB_TOKEN}" \
-H "Content-Type: application/octet-stream" \
--data-binary @"./canvas-linux.tar.gz"
- |
curl -X "POST" "https://uploads.github.com/repos/paritytech/canvas-node/releases/$RELEASE_ID/assets?name=canvas-mac.tar.gz" \
-H "Cookie: logged_in=no" \
-H "Authorization: token ${GITHUB_TOKEN}" \
-H "Content-Type: application/octet-stream" \
--data-binary @"./canvas-mac.tar.gz"