diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5e7cd4116922..1bc15eec6f5e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -92,6 +92,7 @@ test-linux-stable: &test test "${CI_COMMIT_REF_NAME}" = "kusama-nightly-staging" && ( echo "kusama-nightly-staging: change Cargo.toml to build against substrate:kusama-nightly-staging" find . -name Cargo.toml -exec sed -i -r -e ':github.com/paritytech/substrate": { s:branch = "polkadot-(master|testing)":branch = "kusama-nightly-staging":; s:github.com/paritytech/substrate:gitlab.parity.io/parity/substrate.git:}' '{}' \; + sed -i -r 's:github.com/paritytech/substrate\?branch=polkadot-(master|testing):gitlab.parity.io/parity/substrate.git?branch=kusama-nightly-staging:' Cargo.lock time cargo test --all --release --verbose) || \ time cargo test --all --release --verbose --locked - sccache -s @@ -108,8 +109,9 @@ build-linux-release: &build script: - | test "${CI_COMMIT_REF_NAME}" = "kusama-nightly-staging" && ( - echo "kusama-nightly-staging: change Cargo.toml to build against substrate:kusama-nightly-staging"; - find . -name Cargo.toml -exec sed -i -r -e ':github.com/paritytech/substrate": { s:branch = "polkadot-(master|testing)":branch = "kusama-nightly-staging":; s:github.com/paritytech/substrate:gitlab.parity.io/parity/substrate.git:}' '{}' \; ) + echo "kusama-nightly-staging: change Cargo.toml to build against substrate:kusama-nightly-staging" + find . -name Cargo.toml -exec sed -i -r -e ':github.com/paritytech/substrate": { s:branch = "polkadot-(master|testing)":branch = "kusama-nightly-staging":; s:github.com/paritytech/substrate:gitlab.parity.io/parity/substrate.git:}' '{}' \; + sed -i -r 's:github.com/paritytech/substrate\?branch=polkadot-(master|testing):gitlab.parity.io/parity/substrate.git?branch=kusama-nightly-staging:' Cargo.lock ) - time cargo build --release --verbose - mkdir -p ./artifacts - mv ./target/release/polkadot ./artifacts/. @@ -135,6 +137,20 @@ build-linux-release: &build cache: {} <<: *build-refs <<: *kubernetes-env + before_script: + - test -s ./artifacts/VERSION || exit 1 + - LATEST_BRANCH="$(ls -1 .git/refs/remotes/origin/ | sed -r -n 's:v([0-9]+)\.([0-9]+):v\1.\2:p' | sort -V | tail -n1)" + - if [ "${CI_COMMIT_TAG}" ]; then + VERSION="${CI_COMMIT_TAG}"; + else + VERSION="$(cat ./artifacts/VERSION)-$(cut -c 1-8 ./artifacts/polkadot.sha256)"; + fi + - if expr match x${CI_COMMIT_TAG} x${LATEST_BRANCH}; then + EXTRATAG="latest"; + else + EXTRATAG="latest-${CI_COMMIT_REF_NAME}"; + fi + - echo "Polkadot version = ${VERSION} (TAG ${EXTRATAG})" @@ -151,16 +167,11 @@ publish-docker-release: GIT_STRATEGY: none # DOCKERFILE: scripts/docker/Dockerfile CONTAINER_IMAGE: parity/polkadot - before_script: + script: - test "$Docker_Hub_User_Parity" -a "$Docker_Hub_Pass_Parity" || ( echo "no docker credentials provided"; exit 1 ) - docker login -u "$Docker_Hub_User_Parity" -p "$Docker_Hub_Pass_Parity" - docker info - script: - - VERSION="$(cat ./artifacts/VERSION)" - - EXTRATAG="${CI_COMMIT_TAG:-latest}" - - echo "Polkadot version = ${VERSION}" - - test -z "${VERSION}" && exit 1 - cd ./artifacts - docker build --build-arg VCS_REF="${CI_COMMIT_SHA}" @@ -185,19 +196,16 @@ publish-s3-release: BUCKET: "releases.parity.io" PREFIX: "polkadot/${ARCH}-${DOCKER_OS}" script: - - VERSION="${CI_COMMIT_TAG:-$(cat ./artifacts/VERSION)}" - # LATEST_BRANCH will be empty if it's not a tag build i.e. CI_COMMIT_TAG is unset - - LATEST_BRANCH="$(echo $CI_COMMIT_TAG | sed -n -r 's/^(v[0-9]+\.[0-9]+)\.[0-9]+$/\1/p')" - aws s3 sync ./artifacts/ s3://${BUCKET}/${PREFIX}/${VERSION}/ - echo "update objects in latest path" - for file in ./artifacts/*; do name="$(basename ${file})"; aws s3api copy-object --copy-source ${BUCKET}/${PREFIX}/${VERSION}/${name} - --bucket ${BUCKET} --key ${PREFIX}/latest${LATEST_BRANCH}/${name}; + --bucket ${BUCKET} --key ${PREFIX}/${EXTRATAG}/${name}; done after_script: - - aws s3 ls s3://${BUCKET}/${PREFIX}/latest${LATEST_BRANCH}/ + - aws s3 ls s3://${BUCKET}/${PREFIX}/${EXTRATAG}/ --recursive --human-readable --summarize