diff --git a/.cicd/package-builder.sh b/.cicd/package-builder.sh deleted file mode 100755 index 0d3d4652d81..00000000000 --- a/.cicd/package-builder.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env bash -set -eo pipefail -if [[ $(uname) == 'Darwin' ]]; then - echo 'Darwin family detected, building for brew.' - [[ -z $ARTIFACT ]] && ARTIFACT='*.rb;*.tar.gz' - PACKAGE_TYPE='brew' -else - . /etc/os-release - if [[ "$ID_LIKE" == 'debian' || "$ID" == 'debian' ]]; then - echo 'Debian family detected, building for dpkg.' - [[ -z $ARTIFACT ]] && ARTIFACT='*.deb' - PACKAGE_TYPE='deb' - elif [[ "$ID_LIKE" == 'rhel fedora' || "$ID" == 'fedora' ]]; then - echo 'Fedora family detected, building for RPM.' - [[ -z $ARTIFACT ]] && ARTIFACT='*.rpm' - PACKAGE_TYPE='rpm' - mkdir -p ~/rpmbuild/BUILD - mkdir -p ~/rpmbuild/BUILDROOT - mkdir -p ~/rpmbuild/RPMS - mkdir -p ~/rpmbuild/SOURCES - mkdir -p ~/rpmbuild/SPECS - mkdir -p ~/rpmbuild/SRPMS - yum install -y rpm-build - elif [[ $ID == 'amzn' ]]; then - echo "SKIPPED: We do not generate $NAME packages since they use rpms created from Centos." - exit 0 - else - echo 'ERROR: Could not determine which operating system this script is running on!' - uname - echo "ID_LIKE=\"$ID_LIKE\"" - cat /etc/os-release - exit 1 - fi -fi -BASE_COMMIT=$(cat build/programs/nodeos/config.hpp | grep 'version' | awk '{print $5}' | tr -d ';') -BASE_COMMIT="${BASE_COMMIT:2:42}" -echo "Found build against $BASE_COMMIT." -cd build/packages -chmod 755 ./*.sh -./generate_package.sh $PACKAGE_TYPE -[[ -d x86_64 ]] && cd 'x86_64' # backwards-compatibility with release/1.6.x -buildkite-agent artifact upload "./$ARTIFACT" --agent-access-token $BUILDKITE_AGENT_ACCESS_TOKEN -for A in $(echo $ARTIFACT | tr ';' ' '); do - if [[ $(ls $A | grep -c '') == 0 ]]; then - echo "+++ :no_entry: ERROR: Expected artifact \"$A\" not found!" - pwd - ls -la - exit 1 - fi -done \ No newline at end of file diff --git a/.cicd/package.sh b/.cicd/package.sh new file mode 100755 index 00000000000..f1b4e6d23c6 --- /dev/null +++ b/.cicd/package.sh @@ -0,0 +1,66 @@ +#!/usr/bin/env bash +set -eo pipefail +. ./.cicd/helpers/general.sh + +mkdir -p $BUILD_DIR + +if [[ $(uname) == 'Darwin' ]]; then + + bash -c "cd build/packages && chmod 755 ./*.sh && ./generate_package.sh brew" + + ARTIFACT='*.rb;*.tar.gz' + cd build/packages + [[ -d x86_64 ]] && cd 'x86_64' # backwards-compatibility with release/1.6.x + buildkite-agent artifact upload "./$ARTIFACT" --agent-access-token $BUILDKITE_AGENT_ACCESS_TOKEN + for A in $(echo $ARTIFACT | tr ';' ' '); do + if [[ $(ls $A | grep -c '') == 0 ]]; then + echo "+++ :no_entry: ERROR: Expected artifact \"$A\" not found!" + pwd + ls -la + exit 1 + fi + done + +else # Linux + + ARGS=${ARGS:-"--rm --init -v $(pwd):$MOUNTED_DIR"} + + . $HELPERS_DIR/docker-hash.sh + + PRE_COMMANDS="cd $MOUNTED_DIR/build/packages && chmod 755 ./*.sh" + + if [[ "$IMAGE_TAG" =~ "ubuntu" ]]; then + ARTIFACT='*.deb' + PACKAGE_TYPE='deb' + PACKAGE_COMMANDS="./generate_package.sh $PACKAGE_TYPE" + elif [[ "$IMAGE_TAG" =~ "centos" ]]; then + ARTIFACT='*.rpm' + PACKAGE_TYPE='rpm' + PACKAGE_COMMANDS="mkdir -p ~/rpmbuild/BUILD && mkdir -p ~/rpmbuild/BUILDROOT && mkdir -p ~/rpmbuild/RPMS && mkdir -p ~/rpmbuild/SOURCES && mkdir -p ~/rpmbuild/SPECS && mkdir -p ~/rpmbuild/SRPMS && yum install -y rpm-build && ./generate_package.sh $PACKAGE_TYPE" + fi + + COMMANDS="$PRE_COMMANDS && $PACKAGE_COMMANDS" + + # Load BUILDKITE Environment Variables for use in docker run + if [[ -f $BUILDKITE_ENV_FILE ]]; then + evars="" + while read -r var; do + evars="$evars --env ${var%%=*}" + done < "$BUILDKITE_ENV_FILE" + fi + + eval docker run $ARGS $evars $FULL_TAG bash -c \"$COMMANDS\" + + cd build/packages + [[ -d x86_64 ]] && cd 'x86_64' # backwards-compatibility with release/1.6.x + buildkite-agent artifact upload "./$ARTIFACT" --agent-access-token $BUILDKITE_AGENT_ACCESS_TOKEN + for A in $(echo $ARTIFACT | tr ';' ' '); do + if [[ $(ls $A | grep -c '') == 0 ]]; then + echo "+++ :no_entry: ERROR: Expected artifact \"$A\" not found!" + pwd + ls -la + exit 1 + fi + done + +fi \ No newline at end of file diff --git a/.cicd/pipeline.yml b/.cicd/pipeline.yml index 543780d5f6b..41b6444fb49 100644 --- a/.cicd/pipeline.yml +++ b/.cicd/pipeline.yml @@ -245,8 +245,9 @@ steps: - label: ":centos: CentOS 7.6 - Package Builder" command: - "buildkite-agent artifact download build.tar.gz . --step ':centos: CentOS 7.6 - Build' --agent-access-token $$BUILDKITE_AGENT_ACCESS_TOKEN && tar -xzf build.tar.gz" - - "./.cicd/package-builder.sh" + - "./.cicd/package.sh" env: + IMAGE_TAG: "centos-7.6" BUILDKITE_AGENT_ACCESS_TOKEN: agents: queue: "automation-eos-builder-fleet" @@ -256,8 +257,9 @@ steps: - label: ":ubuntu: Ubuntu 16.04 - Package Builder" command: - "buildkite-agent artifact download build.tar.gz . --step ':ubuntu: Ubuntu 16.04 - Build' --agent-access-token $$BUILDKITE_AGENT_ACCESS_TOKEN && tar -xzf build.tar.gz" - - "./.cicd/package-builder.sh" + - "./.cicd/package.sh" env: + IMAGE_TAG: "ubuntu-16.04" BUILDKITE_AGENT_ACCESS_TOKEN: agents: queue: "automation-eos-builder-fleet" @@ -267,8 +269,9 @@ steps: - label: ":ubuntu: Ubuntu 18.04 - Package Builder" command: - "buildkite-agent artifact download build.tar.gz . --step ':ubuntu: Ubuntu 18.04 - Build' --agent-access-token $$BUILDKITE_AGENT_ACCESS_TOKEN && tar -xzf build.tar.gz" - - "./.cicd/package-builder.sh" + - "./.cicd/package.sh" env: + IMAGE_TAG: "ubuntu-18.04" BUILDKITE_AGENT_ACCESS_TOKEN: agents: queue: "automation-eos-builder-fleet" @@ -279,7 +282,7 @@ steps: command: - "git clone $BUILDKITE_REPO eos && cd eos && git checkout $BUILDKITE_COMMIT" - "cd eos && buildkite-agent artifact download build.tar.gz . --step ':darwin: macOS 10.14 - Build' && tar -xzf build.tar.gz" - - "cd eos && ./.cicd/package-builder.sh" + - "cd eos && ./.cicd/package.sh" plugins: - chef/anka#v0.5.1: no-volume: true