-
Notifications
You must be signed in to change notification settings - Fork 0
137 lines (120 loc) · 4.4 KB
/
continuous-build.yml
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
130
131
132
133
134
135
136
137
name: Continuous Build and Publish
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build:
name: Build on ${{ matrix.os }}
strategy:
matrix:
os:
- macos-latest
- ubuntu-latest
- windows-latest
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: '^1.16'
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build archives and test
run: make build test
env:
VERSION: ${{ github.sha }}
- name: Build linux archives
if: ${{ runner.os == 'Linux' }}
run: make packaging
env:
VERSION: ${{ github.sha }}
- name: Configure AWS Credentials
if: ${{ runner.os == 'Linux' && github.event_name == 'push' }}
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: Verify Daemon binary
if: ${{ runner.os == 'Linux' && github.event_name == 'push' }}
run: |
build/xray-linux-amd64/xray -o -l dev &
sleep 10
echo -e '{"format":"json","version":1}\nx' | nc -w 1 -u 127.0.0.1 2000
sleep 10
ProcNumber=$(ps -ef |grep -w xray|grep -v grep|wc -l)
echo $ProcNumber
if [[ $PROCESS_NUM eq 0 ]]; then
exit 1
fi
- name: Download package signing GPG secret key
if: ${{ runner.os == 'Linux' && github.event_name == 'push' }}
run: |
aws secretsmanager get-secret-value --region us-east-1 --secret-id "XRayDaemonSecrets" | jq -r ".SecretString" > aws-xray-secret.gpg
md5sum aws-xray-secret.gpg
- name: Import signing GPG key
if: ${{ runner.os == 'Linux' && github.event_name == 'push' }}
run: |
gpg --import aws-xray-secret.gpg
gpg --list-keys
gpg --armor --export -a "aws-xray@amazon.com" > aws-xray-public.gpg
rpm --import aws-xray-public.gpg
shred -fuvz aws-xray-secret.gpg
shred -fuvz aws-xray-public.gpg
- name: Sign daemon packages
if: ${{ runner.os == 'Linux' && github.event_name == 'push' }}
run: ./Tool/src/packaging/sign-packages.sh
- name: Remove Package Signing GPG Key from local GPG Key Ring
if: ${{ runner.os == 'Linux' && github.event_name == 'push' }}
run: |
gpg --fingerprint --with-colons aws-xray@amazon.com | grep -m 1 "fpr" | sed -n 's/^fpr:::::::::\([[:alnum:]]\+\):/\1/p' | xargs gpg --batch --yes --delete-secret-keys
gpg --list-secret-keys
- name: Upload archives as actions artifact
if: ${{ runner.os == 'Linux' }}
uses: actions/upload-artifact@v2
with:
name: distributions
path: build/dist/
- name: Login to Public ECR
if: ${{ runner.os == 'Linux' && github.event_name == 'push' }}
uses: docker/login-action@v1
with:
registry: public.ecr.aws
- name: Login to DockerHub
if: ${{ runner.os == 'Linux' && github.event_name == 'push' }}
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}
- name: Set up Docker Buildx
if: ${{ runner.os == 'Linux' }}
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build docker image
if: ${{ runner.os == 'Linux' }}
uses: docker/build-push-action@v2
with:
context: .
push: ${{ github.event_name == 'push' }}
platforms: linux/amd64,linux/arm64
tags: |
amazon/aws-xray-daemon:alpha
public.ecr.aws/xray/aws-xray-daemon:alpha
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache