Skip to content

Commit 6190a43

Browse files
authored
v0.3.0 (#4)
* Create dev branch * Update Readme * Add delete & head commands + json & xml payload support * Updates * Trigger build * Update * Updates * Update Readme * Add fire and forget option * Update driver.json * Add custom integration infos * trigger build * Updates
1 parent 7c32458 commit 6190a43

14 files changed

+679
-220
lines changed

.github/workflows/build.yml

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# Manual triggered GitHub action to build a distribution binary of the Python integration driver and attach it to a release draft including a hash file
2+
---
3+
name: "Build & Draft Release"
4+
5+
on:
6+
workflow_dispatch:
7+
push:
8+
branches: dev
9+
10+
env:
11+
INTG_NAME: requests
12+
# Python version to use in the builder image. See https://hub.docker.com/r/unfoldedcircle/r2-pyinstaller for possible versions.
13+
PYTHON_VER: 3.11.6-0.2.0
14+
15+
jobs:
16+
build:
17+
name: Build Release
18+
runs-on: ubuntu-latest
19+
#Save version to env output variable to be able to use it in the following release job as a tag
20+
outputs:
21+
version: ${{ steps.get-version-and-id.outputs.VERSION }}
22+
driver_id: ${{ steps.get-version-and-id.outputs.DRIVER_ID }}
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
with:
27+
# History of 200 should be more than enough to calculate commit count since last release tag
28+
fetch-depth: 200
29+
# Only for testing. Delete when merging with main branch
30+
ref: dev
31+
32+
- name: Get version and id
33+
#Id needed for env output variable
34+
id: get-version-and-id
35+
run: |
36+
echo "VERSION=$(jq .version -r driver.json)" >> $GITHUB_ENV
37+
echo "DRIVER_ID=$(jq .driver_id -r driver.json)" >> $GITHUB_ENV
38+
# Save to Github output to later use it in Create Release job
39+
echo "VERSION=$(jq .version -r driver.json)" >> $GITHUB_OUTPUT
40+
echo "DRIVER_ID=$(jq .driver_id -r driver.json)" >> $GITHUB_OUTPUT
41+
42+
- name: Build
43+
run: |
44+
sudo apt-get update && sudo apt-get install -y qemu binfmt-support qemu-user-static
45+
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
46+
echo "Starting pyinstaller build"
47+
docker run --rm --name builder \
48+
--platform=aarch64 \
49+
--user=$(id -u):$(id -g) \
50+
-v ${GITHUB_WORKSPACE}:/workspace \
51+
docker.io/unfoldedcircle/r2-pyinstaller:${PYTHON_VER} \
52+
bash -c \
53+
"cd /workspace && \
54+
python -m pip install -r requirements.txt && \
55+
pyinstaller --clean --onedir --name intg-${DRIVER_ID} --collect-all zeroconf intg-${INTG_NAME}/driver.py"
56+
57+
- name: Prepare artifacts
58+
shell: bash
59+
run: |
60+
mkdir -p artifacts/bin
61+
mv dist/intg-${{ env.DRIVER_ID }}/* artifacts/bin
62+
mv artifacts/bin/intg-${{ env.DRIVER_ID }} artifacts/bin/driver
63+
cp driver.json artifacts/
64+
echo "ARTIFACT_NAME=uc-intg-${{ env.DRIVER_ID }}-${{ env.VERSION }}-aarch64" >> $GITHUB_ENV
65+
66+
- name: Create upload artifact archive
67+
shell: bash
68+
run: |
69+
tar czvf ${{ env.ARTIFACT_NAME }}.tar.gz -C ${GITHUB_WORKSPACE}/artifacts .
70+
ls -lah
71+
72+
- uses: actions/upload-artifact@v4
73+
id: upload_artifact
74+
with:
75+
name: ${{ env.ARTIFACT_NAME }}
76+
path: ${{ env.ARTIFACT_NAME }}.tar.gz
77+
if-no-files-found: error
78+
retention-days: 3
79+
80+
release:
81+
name: Create Release
82+
runs-on: ubuntu-latest
83+
needs: [build]
84+
permissions:
85+
contents: write
86+
87+
steps:
88+
- name: Download build artifacts
89+
uses: actions/download-artifact@v4
90+
91+
- name: Extract build archives from downloaded files
92+
run: |
93+
ls -R
94+
# extract tar.gz build archives from downloaded artifacts
95+
# (wrapped in tar from actions/upload-artifact, then extracted into a directory by actions/download-artifact)
96+
for D in *
97+
do if [ -d "${D}" ]; then
98+
mv $D/* ./
99+
fi
100+
done;
101+
102+
- name: Create hash file
103+
run: |
104+
for filename in *.tar.gz; do echo "sha256 `sha256sum $filename`" >> ${{needs.build.outputs.driver_id}}.hash; done;
105+
106+
- name: Create release draft
107+
uses: ncipollo/release-action@v1
108+
with:
109+
artifacts: "*.tar.gz,${{needs.build.outputs.driver_id}}.hash"
110+
draft: true
111+
generateReleaseNotes: true
112+
artifactErrorsFailBuild: true
113+
tag: v${{needs.build.outputs.version}}
114+

.gitignore

+6-1
Original file line numberDiff line numberDiff line change
@@ -395,4 +395,9 @@ FodyWeavers.xsd
395395
*.msp
396396

397397
# JetBrains Rider
398-
*.sln.iml
398+
*.sln.iml
399+
400+
# Test and config files
401+
config.json
402+
.venv/
403+
manual-build+upload.sh

.pylintrc

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[FORMAT]
2+
3+
# Maximum number of characters on a single line.
4+
max-line-length=175
5+
6+
[MESSAGES CONTROL]
7+
8+
# Disable the message, report, category or checker with the given id(s). You
9+
# can either give multiple identifiers separated by comma (,) or put this
10+
# option multiple times (only on the command line, not in the configuration
11+
# file where it should appear only once).You can also use "--disable=all" to
12+
# disable everything first and then re-enable specific checks. For example, if
13+
# you want to run only the similarities checker, you can use "--disable=all
14+
# --enable=similarities". If you want to run only the classes checker, but have
15+
# no Warning level messages displayed, use"--disable=all --enable=classes
16+
# --disable=W"
17+
18+
disable=
19+
global-statement,
20+
too-many-instance-attributes,
21+
too-many-arguments,
22+
too-many-public-methods,
23+
fixme # temporary
24+
25+
[STRING]
26+
27+
# This flag controls whether inconsistent-quotes generates a warning when the
28+
# character used as a quote delimiter is used inconsistently within a module.
29+
check-quote-consistency=yes

CHANGELOG.md

+26-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
*Changes in the next release*
11+
12+
### Breaking changes
13+
- **🎉 This integration can now also run on the remote. From now on each release will have a tar.gz file attached that can be installed on the remote** (see [Run on the remote as a custom integration driver](/README.md#Run-on-the-remote-as-a-custom-integration-driver))
14+
- ⚠️ Running custom integrations on the remote is currently only available in beta firmware releases and requires version 1.9.2 or newer. Please keep in mind that due to the beta status there are missing firmware features that require workarounds (see link above) and that changes in future beta updates may temporarily or permanently break the functionality of this integration as a custom integration. Please wait until custom integrations are available in stable firmware releases if you don't want to take these risks.
15+
- When running as an external integration driver the working directory when starting driver.py should now be the root of the repository. The path in docker-entry.sh has been adjusted. The configuration json file is therefore now created in the root of the integration directory. Existing users have to move config.json from the intg-requests directory
16+
17+
### Added
18+
- Support for HTTP delete and head requests
19+
- Support for adding json or xml payload data to a http request (see [Adding payload data](/README.md#adding-payload-data))
20+
- Added an option to ignore HTTP requests errors and always return a OK/200 status code to the remote. Helpful if the server doesn't send any response or closes the connection after a command is received (fire and forget). The error message will still be logged but at debug instead of error level
21+
- The wake-on-lan entity now supports an ipv4/v6 address or a hostname (ipv4 only) as a parameter when running as an external integration
22+
- This feature is not supported when running the integration on the remote due to sandbox limitations
23+
- Discover the mac address from an ip address or a hostname may not work on all systems. Please refer to the [getmac supported platforms](https://github.com/GhostofGoes/getmac?tab=readme-ov-file#platforms-currently-supported). Docker containers need to be run in the host network (`--net=host`)
24+
- Add build.yml Github action to automatically build a self-contained binary of the integration and create a release draft with the current driver version as a tag/name
25+
26+
### Changed
27+
- Due to the custom integration driver upload feature setup.json has been renamed to driver.json and moved to the root of the repository
28+
- Add custom user agent for http requests (uc-intg-requests)
29+
- Corrected the semantic version scheme in driver.json (x.x to x.x.x)
30+
31+
32+
1033
## [0.2-beta] - 2024-06-26
1134

1235
### Breaking changes
@@ -16,11 +39,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1639

1740
- Added a more granular http status code response handling
1841
- Added optional parameter to send form data in the request body as key/value pairs (see README)
19-
- Added optional custom global entity-independent timeout and ssl verify option in the integration setup. For self signed ssl certificates to work the ssl verify option needs to be deactivated.
42+
- Added optional custom global entity-independent timeout and ssl verify options in the integration setup. For self signed ssl certificates to work the ssl verify option needs to be deactivated.
2043

2144
### Changed
2245
- Only return an error response to the remote if the http response code is in the 400 or 500 range. Otherwise display the status code in the integration log if it's not 200/Ok
2346

47+
48+
2449
## [0.1-beta] - 2024-04-27
2550

2651
### Added

0 commit comments

Comments
 (0)