-
Notifications
You must be signed in to change notification settings - Fork 55
129 lines (124 loc) · 5.35 KB
/
release.yml
File metadata and controls
129 lines (124 loc) · 5.35 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: Upload new release
on:
release:
types: [published]
jobs:
build_function:
name: Build function
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Writes the integration name into github env variable called `integration`
- name: Get integraion
id: integration-receiver
run: |
integration=$(echo "${{ github.event.release.tag_name }}" | cut -d- -f2)
echo "integration=${integration}" >> "$GITHUB_ENV"
# Writes the version number into github env variable called `version_without`
- name: Get version clean
id: version-receiver-without
run: |
version=$(echo "${{ github.event.release.tag_name }}" | cut -d- -f1)
version_without=$(echo ${version:1})
echo "version_without=${version_without}" >> "$GITHUB_ENV"
# Zip the code and upload to S3 Bucket
- name: Zip Folder
run: |
if [[ "${{ env.integration }}" = "CloudWatch" ]]; then
cd python3/cloudwatch
make
echo "release_file_path=python3/cloudwatch/dist/logzio-cloudwatch-log-shipper.zip" >> "$GITHUB_ENV"
else
cd python3/kinesis
make
echo "release_file_path=python3/kinesis/dist/logzio-kinesis-log-shipper.zip" >> "$GITHUB_ENV"
fi
- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: ${{ env.release_file_path }}
upload_to_buckets:
name: Upload to S3 buckets
runs-on: ubuntu-latest
needs: build_function
strategy:
matrix:
aws_region:
- 'us-east-1'
- 'us-east-2'
- 'us-west-1'
- 'us-west-2'
- 'eu-central-1'
- 'eu-north-1'
- 'eu-west-1'
- 'eu-west-2'
- 'eu-west-3'
- 'sa-east-1'
- 'ap-northeast-1'
- 'ap-northeast-2'
- 'ap-northeast-3'
- 'ap-south-1'
- 'ap-southeast-1'
- 'ap-southeast-2'
- 'ca-central-1'
steps:
- name: Check out the repo
uses: actions/checkout@v4
# Writes the integration name into github env variable called `integration`
- name: Receive integraion
id: integration-receiver
run: |
integration=$(echo "${{ github.event.release.tag_name }}" | cut -d- -f2)
echo "integration=${integration}" >> "$GITHUB_ENV"
# Writes the version number into github env variable called `version_without`
- name: Receive version clean
id: version-receiver-without
run: |
version=$(echo "${{ github.event.release.tag_name }}" | cut -d- -f1)
version_without=$(echo ${version:1})
echo "version_without=${version_without}" >> "$GITHUB_ENV"
# Download the ZIP to create a new version and upload the AWS
- name: download zip
run: |
if [[ "${{ env.integration }}" = "CloudWatch" ]]; then
wget -c https://github.com/logzio/logzio_aws_serverless/releases/download/${{ github.event.release.tag_name }}/logzio-cloudwatch-log-shipper.zip -O logzio-cloudwatch.zip
else
wget -c https://github.com/logzio/logzio_aws_serverless/releases/download/${{ github.event.release.tag_name }}/logzio-kinesis-log-shipper.zip -O logzio-kinesis.zip
fi
shell: bash
- name: create new version
run: |
if [[ "${{ env.integration }}" = "CloudWatch" ]]; then
cp ./python3/cloudwatch/sam-template.yaml ./sam-template-${{ matrix.aws_region }}.yaml
else
cp ./python3/kinesis/sam-template.yaml ./sam-template-${{ matrix.aws_region }}.yaml
fi
sed -i "s/<<VERSION>>/${{ env.version_without }}/" "./sam-template-${{ matrix.aws_region }}.yaml"
sed -i "s/<<REGION>>/${{ matrix.aws_region }}/" "./sam-template-${{ matrix.aws_region }}.yaml"
shell: bash
- name: Upload to aws
run: |
sudo apt-get update
sudo apt-get install awscli
aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY }}
aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_KEY }}
aws configure set region ${{ matrix.aws_region }}
if [[ "${{ env.integration }}" = "CloudWatch" ]]; then
aws s3 cp ./sam-template-${{ matrix.aws_region }}.yaml s3://logzio-aws-integrations-${{ matrix.aws_region }}/cloudwatch-auto-deployment/${{ env.version_without }}/sam-template.yaml --acl public-read
aws s3 cp ./logzio-cloudwatch.zip s3://logzio-aws-integrations-${{ matrix.aws_region }}/cloudwatch-auto-deployment/${{ env.version_without }}/logzio-cloudwatch.zip --acl public-read
else
aws s3 cp ./sam-template-${{ matrix.aws_region }}.yaml s3://logzio-aws-integrations-${{ matrix.aws_region }}/aws-kinesis/${{ env.version_without }}/auto-deployment.yaml --acl public-read
aws s3 cp ./logzio-kinesis.zip s3://logzio-aws-integrations-${{ matrix.aws_region }}/aws-kinesis/${{ env.version_without }}/logzio-kinesis.zip --acl public-read
fi
shell: bash
- name: Clean
run: |
rm ./sam-template-${{ matrix.aws_region }}.yaml
if [[ "${{ env.integration }}" = "CloudWatch" ]]; then
rm ./logzio-cloudwatch.zip
else
rm ./logzio-kinesis.zip
fi