summaryrefslogtreecommitdiff
path: root/.expeditor/scripts/omnibus_chef_build.sh
blob: d3438c3e8f29d75f5f4c2854bc95e319b3d31317 (plain)
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
#!/bin/bash
set -ueox pipefail

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

export ARTIFACTORY_BASE_PATH="com/getchef"
export ARTIFACTORY_ENDPOINT="https://artifactory-internal.ps.chef.co/artifactory"
export ARTIFACTORY_USERNAME="buildkite"

export PROJECT_NAME="chef"
export PATH="/opt/omnibus-toolchain/bin:${PATH}"
export OMNIBUS_FIPS_MODE="true"
export OMNIBUS_PIPELINE_DEFINITION_PATH="${SCRIPT_DIR}/../release.omnibus.yml"

## hard code for sles-aarch64 here
## condition statement that looks at the slug, then do the hard coding to 
#https://artifactory-internal.ps.chef.co/artifactory/omnibus-current-local/com/getchef/chef-foundation/3.0.6/sles/15/chef-foundation-3.0.6-1.sles15.aarch64.rpm


echo "--- Installing Chef Foundation"
curl -fsSL https://omnitruck.chef.io/chef/install.sh | bash -s -- -c "current" -P "chef-foundation" -v "$CHEF_FOUNDATION_VERSION"

if [[ -f "/opt/omnibus-toolchain/embedded/ssl/certs/cacert.pem" ]]; then
  export SSL_CERT_FILE="/opt/omnibus-toolchain/embedded/ssl/certs/cacert.pem"
fi

if [[ "$BUILDKITE_LABEL" =~ rhel|sles|centos ]] && [[ $BUILDKITE_ORGANIZATION_SLUG != "chef-oss" ]]; then
  export OMNIBUS_RPM_SIGNING_PASSPHRASE=''

  echo "$RPM_SIGNING_KEY" | gpg --import

  cat <<-EOF > ~/.rpmmacros
    %_signature gpg
    %_gpg_name  Opscode Packages
EOF
fi

echo "--- Running bundle install for Omnibus"
cd "${SCRIPT_DIR}/../../omnibus"
bundle config set --local without development
bundle install

echo "--- Building Chef"
bundle exec omnibus build chef -l internal --override append_timestamp:false

echo "--- Uploading package to BuildKite"
extensions=( bff deb dmg msi p5p rpm solaris amd64.sh i386.sh )
for ext in "${extensions[@]}"
do
  buildkite-agent artifact upload "pkg/*.${ext}*"
done

if [[ $BUILDKITE_ORGANIZATION_SLUG != "chef-oss" ]]; then
  echo "--- Setting up Gem credentials"
  export GEM_HOST_API_KEY="Basic ${ARTIFACTORY_API_KEY}"

  echo "--- Publishing package to Artifactory"
  bundle exec ruby "${SCRIPT_DIR}/omnibus_chef_publish.rb"
fi