Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish daemon binaries to staging s3 bucket #139

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
41 changes: 41 additions & 0 deletions .github/workflows/release-build-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,29 @@ on:
major_version:
description: The major version to tag the release with, e.g., 1.x, 2.x, 3.x
required: true
latest_commit_id:
description: Latest commit id of the repository (usually commit id of the release commit)
required: true

jobs:
build_publish_daemon_image:
name: Build X-Ray daemon artifacts and publish docker image to docker hub and public ECR
runs-on: ubuntu-latest
steps:
- name: Validate CI job has passed
uses: fountainhead/[email protected]
id: wait-for-build
with:
token: ${{ secrets.GITHUB_TOKEN }}
# ToDO: check name should be the name of the integration test job once we set up CI workflow
checkName: Build on macos-latest
ref: ${{ github.event.inputs.latest_commit_id }}
timeoutSeconds: 60

- name: Fail CD job if CI job is not passed
if: steps.wait-for-build.outputs.conclusion == 'failure' || steps.wait-for-build.outputs.conclusion == 'timed_out'
run: exit 1

- name: Checkout Repository
uses: actions/checkout@v2

Expand Down Expand Up @@ -135,3 +152,27 @@ jobs:
body: 'Please refer [change-log](https://github.com/aws/aws-xray-daemon/blob/master/CHANGELOG.md) for more details'
draft: true
prerelease: false

publish_to_s3:
name: Publish X-Ray daemon binaries to staging s3 bucket
needs: build_publish_daemon_image
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Download daemon artifacts from Github
uses: actions/download-artifact@v2
with:
name: distributions
path: upload_ready_binaries

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1

- name: Upload packaged binaries to staging s3 bucket
run: s3_bucket_name=aws-xray-assets.staging release_version=${{ github.event.inputs.version }} major_version=${{ github.event.inputs.major_version }} bash Tool/src/publish-s3.sh
87 changes: 87 additions & 0 deletions Tool/src/publish-s3.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#! /bin/bash

set -e

##########################################
# This script is used in X-Ray daemon CD workflow
# to publish X-Ray daemon binaries to s3
#
# Env vars
# 1. s3_bucket_name
# 2. release_version
# 3. major_version
##########################################

# check environment vars
if [ -z ${s3_bucket_name} ]; then
s3_bucket_name="aws-xray-assets.staging"
echo "use default s3_bucket_name: ${s3_bucket_name}"
else
echo "load s3_bucket_name from env var: ${s3_bucket_name}"
fi

# define vars
package_name="aws-xray-daemon"

# check if all the required files are there
declare -a required_files=(
"upload_ready_binaries/${package_name}-${major_version}.deb"
"upload_ready_binaries/${package_name}-${major_version}.rpm"
"upload_ready_binaries/${package_name}-arm64-${major_version}.deb"
"upload_ready_binaries/${package_name}-arm64-${major_version}.rpm"
"upload_ready_binaries/${package_name}-linux-${major_version}.zip"
"upload_ready_binaries/${package_name}-linux-${major_version}.zip.sig"
"upload_ready_binaries/${package_name}-linux-amd64-${release_version}.deb"
"upload_ready_binaries/${package_name}-linux-amd64-${release_version}.rpm"
"upload_ready_binaries/${package_name}-linux-amd64-${release_version}.zip"
"upload_ready_binaries/${package_name}-linux-amd64-${release_version}.zip.sig"
"upload_ready_binaries/${package_name}-linux-amd64-${major_version}.deb"
"upload_ready_binaries/${package_name}-linux-amd64-${major_version}.rpm"
"upload_ready_binaries/${package_name}-linux-amd64-${major_version}.zip"
"upload_ready_binaries/${package_name}-linux-amd64-${major_version}.zip.sig"
"upload_ready_binaries/${package_name}-linux-arm64-${release_version}.deb"
"upload_ready_binaries/${package_name}-linux-arm64-${release_version}.rpm"
"upload_ready_binaries/${package_name}-linux-arm64-${release_version}.zip"
"upload_ready_binaries/${package_name}-linux-arm64-${release_version}.zip.sig"
"upload_ready_binaries/${package_name}-linux-arm64-${major_version}.deb"
"upload_ready_binaries/${package_name}-linux-arm64-${major_version}.rpm"
"upload_ready_binaries/${package_name}-linux-arm64-${major_version}.zip"
"upload_ready_binaries/${package_name}-linux-arm64-${major_version}.zip.sig"
"upload_ready_binaries/${package_name}-macos-${major_version}.zip"
"upload_ready_binaries/${package_name}-macos-${major_version}.zip.sig"
"upload_ready_binaries/${package_name}-macos-amd64-${release_version}.zip"
"upload_ready_binaries/${package_name}-macos-amd64-${release_version}.zip.sig"
"upload_ready_binaries/${package_name}-macos-amd64-${major_version}.zip"
"upload_ready_binaries/${package_name}-macos-amd64-${major_version}.zip.sig"
"upload_ready_binaries/${package_name}-macos-arm64-${release_version}.zip"
"upload_ready_binaries/${package_name}-macos-arm64-${release_version}.zip.sig"
"upload_ready_binaries/${package_name}-macos-arm64-${major_version}.zip"
"upload_ready_binaries/${package_name}-macos-arm64-${major_version}.zip.sig"
"upload_ready_binaries/${package_name}-windows-amd64-${release_version}.zip"
"upload_ready_binaries/${package_name}-windows-amd64-${release_version}.zip.sig"
"upload_ready_binaries/${package_name}-windows-amd64-${major_version}.zip"
"upload_ready_binaries/${package_name}-windows-amd64-${major_version}.zip.sig"
"upload_ready_binaries/${package_name}-windows-amd64-service-${release_version}.zip"
"upload_ready_binaries/${package_name}-windows-amd64-service-${release_version}.zip.sig"
"upload_ready_binaries/${package_name}-windows-amd64-service-${major_version}.zip"
"upload_ready_binaries/${package_name}-windows-amd64-service-${major_version}.zip.sig"
"upload_ready_binaries/${package_name}-windows-process-${major_version}.zip"
"upload_ready_binaries/${package_name}-windows-process-${major_version}.zip.sig"
"upload_ready_binaries/${package_name}-windows-service-${major_version}.zip"
"upload_ready_binaries/${package_name}-windows-service-${major_version}.zip.sig"
)

# check required files are available
for i in "${required_files[@]}"
do
if [ ! -f "${i}" ]; then
echo "${i} does not exist"
exit 1
fi
done

# upload daemon binaries to s3
for i in "${required_files[@]}"
do
aws s3api put-object --bucket "${s3_bucket_name}" --key "${release_version}/${i}" --body "${i}"
done