-
Notifications
You must be signed in to change notification settings - Fork 59
96 lines (84 loc) · 3.5 KB
/
macos.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
name: Build
on:
workflow_dispatch:
inputs:
otp-ref-name:
default: "OTP-27.0.1"
openssl-version:
default: "3.1.6"
# TODO: remove push: before merging
push:
concurrency: builds_txt
jobs:
build:
name: "Build OTP macOS ${{ matrix.arch }}"
runs-on: macos-latest
env:
# TODO: Remove ` || ...` before merging.
OTP_REF_NAME: ${{ inputs.otp-ref-name || 'OTP-27.0.1' }}
OPENSSL_VERSION: ${{ inputs.openssl-version || '3.1.6' }}
OTP_DIR: /tmp/builds/otp-${{ inputs.otp-ref-name || 'OTP-27.0.1' }}-openssl-${{ inputs.openssl-version || '3.1.6' }}-macos-${{ matrix.arch }}
# TODO: use {{ github.sha }}
OTP_REF: OTP-27.0.1
strategy:
matrix:
arch: [amd64, arm64]
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: /tmp/builds/openssl-${{ env.OPENSSL_VERSION }}-macos-${{ matrix.arch }}
key: openssl-${{ env.OPENSSL_VERSION }}-macos-${{ matrix.arch }}
- uses: actions/cache@v4
with:
path: ${{ env.OTP_DIR }}
key: otp-${{ env.OTP_REF_NAME }}-openssl-${{ env.OPENSSL_VERSION }}-macos-${{ matrix.arch }}
- name: Build
run: |
sh priv/scripts/otp/build_otp_macos.sh "${{ env.OTP_REF_NAME }}" "${{ env.OTP_REF_NAME }}" "${{ matrix.arch }}"
- name: Upload
run: |
function purge_key() {
curl \
--fail \
--retry 10 \
-X POST \
-H "Fastly-Key: ${FASTLY_KEY}" \
-H "Accept: application/json" \
-H "Content-Length: 0" \
"https://api.fastly.com/service/${FASTLY_SERVICE_ID}/purge/$1"
}
ref_name=${{ env.OTP_REF_NAME }}
tgz=${{ env.OTP_REF_NAME }}.tar.gz
tar czf ${tgz} --cd ${{ env.OTP_DIR }} .
s3_base_url="s3://${{ env.AWS_S3_BUCKET }}/builds/otp/${{ matrix.arch }}/macos"
# Upload tar.gz
surrogate_key="builds/otp/${{ matrix.arch }}/macos/${{ env.OTP_REF_NAME }}"
aws s3 cp \
${tgz} \
"${s3_base_url}/${tgz}" \
--cache-control "public,max-age=3600" \
--metadata '{"surrogate-key":"builds builds/otp ${surrogate_key}","surrogate-control":"public,max-age=604800"}'
purge_key ${surrogate_key}
# Upload builds.txt
date=$(date -u '+%Y-%m-%dT%H:%M:%SZ')
build_sha256=$(shasum -a 256 $tgz | cut -d ' ' -f 1)
aws s3 cp ${s3_base_url}/builds.txt builds.txt || true
touch builds.txt
sed -i.bak "/^${ref_name} /d" builds.txt
echo -e "${ref_name} ${{ env.OTP_REF }} ${date} ${build_sha256}\n$(cat builds.txt)" > builds.txt
sort -u -k1,1 -o builds.txt builds.txt
surrogate_key="builds/otp/${{ matrix.arch }}/macos/builds.txt"
aws s3 cp \
builds.txt \
${s3_base_url}/builds.txt \
--cache-control "public,max-age=3600" \
--metadata '{"surrogate-key":"builds builds/otp ${surrogate_key}","surrogate-control":"public,max-age=604800"}'
purge_key ${surrogate_key}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.BUILDS_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.BUILDS_AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.BUILDS_AWS_REGION }}
AWS_S3_BUCKET: ${{ secrets.BUILDS_AWS_S3_BUCKET }}
FASTLY_SERVICE_ID: ${{ secrets.BUILDS_FASTLY_SERVICE_ID }}
FASTLY_KEY: ${{ secrets.BUILDS_FASTLY_KEY }}