-
-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathaction.yml
184 lines (172 loc) · 5.54 KB
/
action.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
name: "Home Assistant wheels builder"
description: "Builds and publishes python wheels"
inputs:
tag:
description: "The tag for the builder that should be used"
default: "dev"
arch:
description: "Build architecture"
required: true
apk:
description: "apk packages that should be installed"
default: "build-base"
pip:
description: "pip packages that should be installed"
default: "Cython"
path:
description: "The path to be used for the builder"
default: ""
env-file:
description: "Set to true if the builder should use a env file"
default: false
requirements:
description: "The requirements file"
default: ""
requirements-diff:
description: "The requirements diff file"
default: ""
constraints:
description: "The constraints file"
default: ""
local:
description: "Set to true if local"
default: false
test:
description: "Set to true if not uploading wheels"
default: false
single:
description: "Set to true if should build each wheel as a single prosess"
default: false
name:
description: "Job name"
default: "Wheels"
skip-binary:
description: "Skip binaries"
default: ""
audit:
description: "Audit wheels"
default: false
wheels-key:
description: "SSH keys for the wheels host"
required: false
wheels-host:
description: "wheels host URL"
default: "wheels.hass.io"
wheels-user:
description: "User for wheels host"
default: "wheels"
wheels-index:
description: "The wheels index URL"
default: "https://wheels.home-assistant.io"
runs:
using: "composite"
steps:
- shell: bash
run: |
if [[ "${{ inputs.test }}" =~ false|False ]]; then
mkdir -p .ssh
echo -e "-----BEGIN RSA PRIVATE KEY-----\n${{ inputs.wheels-key }}\n-----END RSA PRIVATE KEY-----" >> .ssh/id_rsa
ssh-keyscan -H ${{ inputs.wheels-host }} >> .ssh/known_hosts
chmod 600 .ssh/*
fi
- shell: bash
id: pull
run: |
name="homeassistant/${{ inputs.arch }}-base-python:${{ inputs.tag }}"
docker pull "$name"
echo "::set-output name=name::$name"
- shell: bash
id: options
run: |
declare -a build
declare -a docker
# Data Path
if [ -n "${{ inputs.path }}" ]; then
data_path="${{ github.workspace }}/${{ inputs.path }}"
else
data_path="${{ github.workspace }}"
fi
# Environment
if [[ "${{ inputs.env-file }}" =~ true|True ]] && [ -f .env_file ]; then
docker+=("--env-file .env_file")
fi
if [ -f "${{ inputs.requirements }}" ]; then
build+=("--requirement ${{ inputs.requirements }}")
fi
if [ -f "${{ inputs.requirements-diff }}" ]; then
build+=("--requirement-diff ${{ inputs.requirements-diff }}")
fi
if [ -f "${{ inputs.constraints }}" ]; then
build+=("--constraint ${{ inputs.constraints }}")
fi
if [ -d "${{ inputs.prebuild-dir }}" ]; then
build+=("--prebuild-dir ${{ inputs.prebuild-dir }}")
fi
if [[ "${{ inputs.single }}" =~ true|True ]]; then
build+=("--single")
fi
if [[ "${{ inputs.local }}" =~ true|True ]]; then
build+=("--local")
fi
if [[ "${{ inputs.test }}" =~ true|True ]]; then
build+=("--test")
fi
if [[ "${{ inputs.audit }}" =~ true|True ]]; then
build+=("--auditwheel")
fi
if [ -n "${{ inputs.skip-binary }}" ]; then
build+=("--skip-binary ${{ inputs.skip-binary }}")
fi
echo "::set-output name=build::${build[@]}"
echo "::set-output name=docker::${docker[@]}"
echo "::set-output name=path::$data_path"
- shell: bash
run: |
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- shell: bash
run: |
echo "Build image"
docker build ${{ github.action_path }} \
-t wheels-builder \
--build-arg BUILD_FROM=${{ steps.pull.outputs.name }} \
--build-arg BUILD_ARCH=${{ inputs.arch }}
- shell: bash
run: |
echo "Create container"
docker create --name "${{ inputs.name }}" -t \
--workdir /data \
${{ steps.options.outputs.docker }} \
"wheels-builder" \
--apk "${{ inputs.apk }}" \
--pip "${{ inputs.pip }}" \
--index "${{ inputs.wheels-index }}" \
--upload rsync \
--remote "${{ inputs.wheels-user }}@${{ inputs.wheels-host }}:/opt/wheels" \
--arch "${{ inputs.arch }}" \
--tag "${{ inputs.tag }}" \
${{ steps.options.outputs.build }}
- shell: bash
run: |
echo "Copy repository and SSH files to the container"
docker cp "${{ steps.options.outputs.path }}/." "${{ inputs.name }}:/data"
if [[ "${{ inputs.test }}" =~ false|False ]]; then
docker cp -a .ssh/ "${{ inputs.name }}:/root/.ssh"
fi
- shell: bash
id: build
run: |
set +e
for i in {1..3}; do
echo "$i attempt on starting the container"
docker start -a "${{ inputs.name }}"
return_val=$?
if [ ${return_val} -ne 0 ] && [ ${return_val} -ne 109 ] && [ ${return_val} -ne 80 ]; then
continue
fi
break
done
echo "::set-output name=return_val::$return_val"
- shell: bash
run: |
docker rm -f "${{ inputs.name }}"
exit ${{ steps.build.outputs.return_val }}