-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make repository usable in GitHub Action (#147)
* Make repository usable in GitHub Action * let's try something else * quote * drop it * go back * fix copy * Fix syntax * add quemu * sudo * fix missing * remove setup * add test * limit pip * use variable * add elf back
- Loading branch information
Showing
6 changed files
with
189 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
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 not uploading wheels" | ||
default: false | ||
test: | ||
description: "Set to true if local" | ||
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: true | ||
wheels-host: | ||
description: "SSH keys for the wheels host" | ||
required: true | ||
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: | | ||
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/* | ||
- 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" ] && [ -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" ]; then | ||
build+=("--single") | ||
fi | ||
if [ "${{ inputs.local }}" == "True" ]; then | ||
build+=("--local") | ||
fi | ||
if [ "${{ inputs.audit }}" == "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: | | ||
sudo apt-get update --fix-missing | ||
sudo apt-get install -y qemu binfmt-support qemu-user-static | ||
- 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" \ | ||
${{ 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" | ||
#docker cp -a .ssh/ "${{ inputs.name }}:/root/.ssh" | ||
- shell: bash | ||
id: build | ||
run: | | ||
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters