Skip to content

Commit df1ba5e

Browse files
reakaleekv1vkruskall
authored
Jenkins 2 GH Actions Workflow Migration (#362)
* Create goreleaser config * Add test workflow * Adjust scripts * Adjust scripts for release * Remove draft flag * Fix NOTICE.txt rule * Remove deprecated files * Add smoke test rules again * Remove outputs * Add slack notification * Update .ci/publish-aws.sh Co-authored-by: Victor Martinez <[email protected]> * Adjust shebang * Use make to the release * Move test command to Makfile * Fix build command * Add opentelemtry workflow * Add opencontainers labels * Use more specific version for vault-action * Fix build test * Run build on a seperate job * Pin gotestsum version * Make sure extension file filename is consistent in docker iamge * Add description to scripts * Use env to create docker image tag * Formatting * Mark PHONY rules * Use Make rule for notice.txt * Move check-licences to Makefile rule * Move notice check to Makefile rule * Move to Makefile rule * Remove excess newlines * Use new channel name * Move to Makefile rule * Set access and modification times for reproducible builds * Fix docker build in test * Use `go run ...` instead of binary * Update .ci/publish-aws.sh Co-authored-by: Victor Martinez <[email protected]> * Add compatible-architectures metadata * Delete zip without custom build_time and rename the zip to the original name * Remove check-extension rule * Use goreleaser's mtime option to set the buildinfo in archives * Fix Dockerfile * Use existing .CommitTimestamp * Set mtime also for files * Remove unused SOURCE_DATE_EPOCH * Add zip rule * Refactor * Add .PHONY where missing * Failsafe clean rule * Update Dockerfile Co-authored-by: kruskall <[email protected]> * Update Dockerfile Co-authored-by: kruskall <[email protected]> --------- Co-authored-by: Victor Martinez <[email protected]> Co-authored-by: kruskall <[email protected]>
1 parent d1488cd commit df1ba5e

15 files changed

+426
-530
lines changed

.ci/Jenkinsfile

-248
This file was deleted.

.ci/jobs/apm-aws-lambda-mbp.yml

-45
This file was deleted.

.ci/publish-aws.sh

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
#
5+
# Publishes the created artifacts from GoReleaser to AWS as AWS Lambda Layers in every region.
6+
# Finalized by generating an ARN table which will be used in the release notes.
7+
#
8+
9+
export AWS_FOLDER=${AWS_FOLDER:-.aws}
10+
export SUFFIX_ARN_FILE=${SUFFIX_ARN_FILE:-arn-file.md}
11+
12+
GOOS=${GOOS:?Please provide GOOS environment variable.}
13+
GOARCH=${GOARCH:?Please provide GOARCH environment variable.}
14+
ELASTIC_LAYER_NAME=${ELASTIC_LAYER_NAME:?Please provide ELASTIC_LAYER_NAME environment variable.}
15+
ARCHITECTURE=${ARCHITECTURE:?Please provide ARCHITECTURE environment variable.}
16+
VERSION=${VERSION:?Please provide VERSION environment variable. e.g. current git tag}
17+
18+
FULL_LAYER_NAME="${ELASTIC_LAYER_NAME}-${ARCHITECTURE}"
19+
20+
ALL_AWS_REGIONS=$(aws ec2 describe-regions --output json --no-cli-pager | jq -r '.Regions[].RegionName')
21+
22+
rm -rf "${AWS_FOLDER}"
23+
24+
# Delete previous layers
25+
for region in $ALL_AWS_REGIONS; do
26+
layer_versions=$(aws lambda list-layer-versions --region="${region}" --layer-name="${FULL_LAYER_NAME}" | jq '.LayerVersions[].Version')
27+
echo "Found layer versions for ${FULL_LAYER_NAME} in ${region}: ${layer_versions:-none}"
28+
for version_number in $layer_versions; do
29+
echo "- Deleting ${FULL_LAYER_NAME}:${version_number} in ${region}"
30+
aws lambda delete-layer-version \
31+
--region="${region}" \
32+
--layer-name="${FULL_LAYER_NAME}" \
33+
--version-number="${version_number}"
34+
done
35+
done
36+
37+
mkdir -p "${AWS_FOLDER}"
38+
39+
zip_file="./dist/${VERSION}-${GOOS}-${GOARCH}.zip"
40+
41+
for region in $ALL_AWS_REGIONS; do
42+
echo "Publish ${FULL_LAYER_NAME} in ${region}"
43+
publish_output=$(aws lambda \
44+
--output json \
45+
publish-layer-version \
46+
--region="${region}" \
47+
--layer-name="${FULL_LAYER_NAME}" \
48+
--compatible-architectures="${ARCHITECTURE}" \
49+
--description="AWS Lambda Extension Layer for Elastic APM ${ARCHITECTURE}" \
50+
--license="Apache-2.0" \
51+
--zip-file="fileb://${zip_file}")
52+
echo "${publish_output}" > "${AWS_FOLDER}/${region}"
53+
layer_version=$(echo "${publish_output}" | jq '.Version')
54+
echo "Grant public layer access ${FULL_LAYER_NAME}:${layer_version} in ${region}"
55+
grant_access_output=$(aws lambda \
56+
--output json \
57+
add-layer-version-permission \
58+
--region="${region}" \
59+
--layer-name="${FULL_LAYER_NAME}" \
60+
--action="lambda:GetLayerVersion" \
61+
--principal='*' \
62+
--statement-id="${FULL_LAYER_NAME}" \
63+
--version-number="${layer_version}")
64+
echo "${grant_access_output}" > "${AWS_FOLDER}/.${region}-public"
65+
done
66+
67+
sh -c "./.ci/create-arn-table.sh"

0 commit comments

Comments
 (0)