-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
action.yml
192 lines (179 loc) · 5.79 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
185
186
187
188
189
190
191
192
name: "Home Assistant wheels builder"
description: "Builds and publishes python wheels"
inputs:
tag:
description: "The musllinux tag for the builder that should be used"
required: true
abi:
description: "CPython ABI that is used"
required: true
arch:
description: "Build architecture"
required: true
apk:
description: "apk packages that should be installed"
default: ""
pip:
description: "pip packages that should be installed"
default: ""
path:
description: "The path to be used for the builder"
default: ""
prebuild-dir:
description: "The directory for prebuild"
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: ""
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
id: version
run: |
input="${GITHUB_ACTION_PATH##*/}"
if [[ "${input}" == "master" ]] || [[ -z "${input}" ]]; then
input="dev"
fi
echo "version=${input}" >> $GITHUB_OUTPUT
- shell: bash
run: |
if [[ "${{ inputs.test }}" =~ false|False ]]; then
# Write Key
mkdir -p .ssh
echo -e "-----BEGIN RSA PRIVATE KEY-----\n${{ inputs.wheels-key }}\n-----END RSA PRIVATE KEY-----" >> .ssh/id_rsa
chmod 600 .ssh/id_rsa
# Validate & update known_hosts
ssh-keygen -y -e -f .ssh/id_rsa
ssh-keyscan -H ${{ inputs.wheels-host }} >> .ssh/known_hosts
chmod 600 .ssh/*
fi
- shell: bash
id: pull
run: |
name="ghcr.io/home-assistant/wheels/${{ inputs.arch }}/${{ inputs.tag }}/${{ inputs.abi }}:${{ steps.version.outputs.version }}"
docker pull "$name"
echo "name=$name" >> $GITHUB_OUTPUT
- 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 ${{ github.workspace }}/${{ 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 [ -n "${{ inputs.skip-binary }}" ]; then
build+=("--skip-binary \"${{ inputs.skip-binary }}\"")
fi
if [ -n "${{ inputs.apk }}" ]; then
build+=("--apk \"${{ inputs.apk }}\"")
fi
if [ -n "${{ inputs.pip }}" ]; then
build+=("--pip \"${{ inputs.pip }}\"")
fi
echo "build=${build[@]}" >> $GITHUB_OUTPUT
echo "docker=${docker[@]}" >> $GITHUB_OUTPUT
echo "path=$data_path" >> $GITHUB_OUTPUT
- shell: bash
run: |
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- shell: bash
run: |
echo "Create container"
docker create --name "${{ inputs.name }}" -t \
--workdir /data \
${{ steps.options.outputs.docker }} \
${{ steps.pull.outputs.name }} \
--index "${{ inputs.wheels-index }}" \
--upload rsync \
--remote "${{ inputs.wheels-user }}@${{ inputs.wheels-host }}:/opt/wheels" \
${{ 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 "return_val=$return_val" >> $GITHUB_OUTPUT
- shell: bash
run: |
docker rm -f "${{ inputs.name }}"
exit ${{ steps.build.outputs.return_val }}