Skip to content

Commit f4b6a87

Browse files
committed
Add cross-compile action.
1 parent 3dcaebb commit f4b6a87

File tree

8 files changed

+449
-74
lines changed

8 files changed

+449
-74
lines changed

.github/workflows/release.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v[0-9]+.[0-9]+.[0-9]+'
7+
8+
jobs:
9+
create-release:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Create Release
13+
id: create_release
14+
uses: actions/create-release@v1.0.0
15+
env:
16+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17+
with:
18+
tag_name: ${{ github.ref }}
19+
release_name: Release ${{ github.ref }}
20+
draft: false
21+
prerelease: false
22+
- run: echo ::set-env name=UPLOAD_URL::'${{ steps.create_release.outputs.upload_url }}' > upload_url
23+
- name: Upload upload_url
24+
uses: actions/upload-artifact@v1
25+
with:
26+
name: upload_url
27+
path: upload_url
28+
29+
build:
30+
needs: create-release
31+
strategy:
32+
matrix:
33+
platform: [
34+
'linux-arm',
35+
'linux-arm64',
36+
'linux-x64',
37+
'darwin-x64',
38+
]
39+
pair: [
40+
'node:10',
41+
'node:12',
42+
'node:14',
43+
]
44+
include:
45+
- platform: 'linux-arm'
46+
host-os: 'ubuntu-latest'
47+
- platform: 'linux-arm64'
48+
host-os: 'ubuntu-latest'
49+
- platform: 'linux-x64'
50+
host-os: 'ubuntu-latest'
51+
- platform: 'darwin-x64'
52+
host-os: 'macos-latest'
53+
- pair: 'node:10'
54+
language: 'node'
55+
version: '10'
56+
- pair: 'node:12'
57+
language: 'node'
58+
version: '12'
59+
- pair: 'node:14'
60+
language: 'node'
61+
version: '14'
62+
63+
runs-on: ${{ matrix.host-os }}
64+
65+
steps:
66+
- name: Download upload_url
67+
uses: actions/download-artifact@v1
68+
with:
69+
name: upload_url
70+
- name: Set upload_url env var
71+
run: cat upload_url/upload_url
72+
- name: Set env
73+
run: echo ::set-env name=RELEASE_VERSION::$(echo ${GITHUB_REF:11})
74+
- uses: actions/checkout@v2
75+
- name: Use Node.js ${{ matrix.version }}
76+
uses: actions/setup-node@v1
77+
with:
78+
node-version: ${{ matrix.version }}
79+
- name: Build adapter
80+
run: |
81+
./build.sh "${{ matrix.platform }}" "${{ matrix.language }}" "${{ matrix.version }}"
82+
- name: Upload Release Asset
83+
id: upload-release-asset
84+
uses: actions/upload-release-asset@v1.0.1
85+
env:
86+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
87+
with:
88+
upload_url: ${{ env.UPLOAD_URL }}
89+
asset_path: voice-addon-${{ env.RELEASE_VERSION }}-${{ matrix.platform }}-v${{ matrix.version }}.tgz
90+
asset_name: voice-addon-${{ env.RELEASE_VERSION }}-${{ matrix.platform }}-v${{ matrix.version }}.tgz
91+
asset_content_type: application/zip
92+
- name: Upload Release Asset Checksum
93+
id: upload-release-asset-checksum
94+
uses: actions/upload-release-asset@v1.0.1
95+
env:
96+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
97+
with:
98+
upload_url: ${{ env.UPLOAD_URL }}
99+
asset_path: voice-addon-${{ env.RELEASE_VERSION }}-${{ matrix.platform }}-v${{ matrix.version }}.tgz.sha256sum
100+
asset_name: voice-addon-${{ env.RELEASE_VERSION }}-${{ matrix.platform }}-v${{ matrix.version }}.tgz.sha256sum
101+
asset_content_type: text/plain

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# voice-addon
22

33
A voice add-on for the
4-
[Mozilla WebThings Gateway](https://github.com/mozilla-iot/gateway) which uses
4+
[WebThings Gateway](https://github.com/WebThingsIO/gateway) which uses
55
[DeepSpeech](https://github.com/mozilla/DeepSpeech) as the speech-to-text (STT)
66
engine.
77

build.sh

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/bin/bash -e
2+
3+
ADDON_ARCH="$1"
4+
LANGUAGE_NAME="$2"
5+
LANGUAGE_VERSION="$3"
6+
7+
function map_posix_tools() {
8+
tar() {
9+
gtar "$@"
10+
return $!
11+
}
12+
export -f tar
13+
14+
readlink() {
15+
greadlink "$@"
16+
return $!
17+
}
18+
export -f readlink
19+
20+
find() {
21+
gfind "$@"
22+
return $!
23+
}
24+
export -f find
25+
}
26+
27+
function install_osx_compiler() {
28+
brew install \
29+
boost \
30+
cmake \
31+
coreutils \
32+
eigen \
33+
findutils \
34+
gnu-tar \
35+
pkg-config
36+
map_posix_tools
37+
}
38+
39+
function install_linux_cross_compiler() {
40+
sudo apt -qq update
41+
sudo apt install --no-install-recommends -y \
42+
binfmt-support \
43+
qemu \
44+
qemu-user-static
45+
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
46+
}
47+
48+
function build_native() {
49+
ADDON_ARCH=${ADDON_ARCH} ./package.sh
50+
}
51+
52+
function build_cross_compiled() {
53+
docker run --rm -t -v $PWD:/build webthingsio/toolchain-${ADDON_ARCH}-${LANGUAGE_NAME}-${LANGUAGE_VERSION} bash -c "cd /build; ADDON_ARCH=${ADDON_ARCH} ./package.sh"
54+
}
55+
56+
case "${ADDON_ARCH}" in
57+
darwin-x64)
58+
install_osx_compiler
59+
build_native
60+
;;
61+
62+
linux-arm)
63+
install_linux_cross_compiler
64+
build_cross_compiled
65+
;;
66+
67+
linux-arm64)
68+
install_linux_cross_compiler
69+
build_cross_compiled
70+
;;
71+
72+
linux-x64)
73+
install_linux_cross_compiler
74+
build_cross_compiled
75+
;;
76+
77+
*)
78+
echo "Unsupported architecture"
79+
exit 1
80+
;;
81+
esac

lib/adapter.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,22 +70,31 @@ class VoiceAdapter extends Adapter {
7070
return false;
7171
}
7272

73+
const clientDevices = await this._client.getDevices();
74+
const clientDevice = clientDevices.find((d) => d.href() === device.href);
75+
if (!clientDevice) {
76+
return false;
77+
}
78+
79+
const clientProperty = clientDevice.properties[property[0]];
80+
if (!clientProperty) {
81+
return false;
82+
}
83+
7384
if (input.hasOwnProperty('value')) {
74-
await this._client.setProperty(property[1], property[0], input.value);
85+
await clientProperty.setValue(input.value);
7586
return true;
7687
}
7788

7889
if (input.hasOwnProperty('adjustment')) {
79-
const currentValue =
80-
await this._client.getProperty(property[1], property[0]);
90+
const currentValue = await clientProperty.getValue();
8191
const newValue = currentValue + input.adjustment;
82-
await this._client.setProperty(property[1], property[0], newValue);
92+
await clientProperty.setValue(newValue);
8393
return true;
8494
}
8595

8696
if (input.hasOwnProperty('queryValue')) {
87-
const currentValue =
88-
await this._client.getProperty(property[1], property[0]);
97+
const currentValue = await clientProperty.getValue();
8998
return currentValue === input.queryValue;
9099
}
91100

manifest.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"author": "Mozilla IoT",
2+
"author": "WebThingsIO",
33
"description": "Hands-free voice addon with personalized keyword and local voice processing.",
44
"gateway_specific_settings": {
55
"webthings": {
@@ -9,7 +9,7 @@
99
"strict_min_version": "0.10.0"
1010
}
1111
},
12-
"homepage_url": "https://github.com/mozilla-iot/voice-addon",
12+
"homepage_url": "https://github.com/WebThingsIO/voice-addon",
1313
"id": "voice-addon",
1414
"license": "MPL-2.0",
1515
"manifest_version": 1,
@@ -81,5 +81,5 @@
8181
}
8282
},
8383
"short_name": "Voice",
84-
"version": "2.1.0"
84+
"version": "2.1.1"
8585
}

0 commit comments

Comments
 (0)