mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-01-12 00:02:53 +00:00
* 15min prices WIP * WIP more changes for 15min prices * More work on 15min pricing * Fixed some errors * Some changes after testing * Graphical changes for 15min pricing * Adjustments on MQTT handlers after switching to 15min prices * Reverted some MQTT changes * Adapted HA integration for 15min pricing * Adapted JSON payload for 15min * Adjustments during testing * Set default price interval * Fixed refresh of price graph when data changes * Bugfixes * Fixed some issues with raw payload * Adjustments for meter timestamp from Kamstrup * Updated readme * Added detailed breakdown of payloads coming from Norwegian meters * Minor changes relating to price * Fixed byte alignment on price config * Changes to support RC upgraders
137 lines
4.9 KiB
YAML
137 lines
4.9 KiB
YAML
name: Build with env and deploy
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
env:
|
|
description: 'The environment to build for'
|
|
required: true
|
|
type: string
|
|
upload_url:
|
|
description: 'The upload URL for the release assets'
|
|
required: true
|
|
type: string
|
|
version:
|
|
description: 'The version tag for the release assets'
|
|
required: true
|
|
type: string
|
|
subfolder:
|
|
description: 'The subfolder in S3 to upload the binary to'
|
|
required: false
|
|
type: string
|
|
default: ''
|
|
is_esp32:
|
|
description: 'Whether the build is for ESP32 based firmware'
|
|
required: false
|
|
type: boolean
|
|
default: true
|
|
|
|
jobs:
|
|
build-and-deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Check out code from repo
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Configure AWS credentials
|
|
uses: aws-actions/configure-aws-credentials@v2
|
|
with:
|
|
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
|
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
|
aws-region: eu-north-1
|
|
|
|
- name: Cache Python dependencies
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/.cache/pip
|
|
key: ${{ runner.os }}-pip-${{ hashFiles('platformio.ini') }}
|
|
|
|
- name: Cache PlatformIO dependencies
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/.pio/libdeps
|
|
key: ${{ runner.os }}-pio-${{ hashFiles('platformio.ini') }}
|
|
|
|
- name: Set up Python 3.9
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: 3.9
|
|
|
|
- name: Inject secrets into ini file
|
|
run: |
|
|
sed -i 's/NO_AMS2MQTT_PRICE_KEY/AMS2MQTT_PRICE_KEY="${{secrets.AMS2MQTT_PRICE_KEY}}"/g' platformio.ini
|
|
sed -i 's/NO_AMS2MQTT_PRICE_AUTHENTICATION/AMS2MQTT_PRICE_AUTHENTICATION="${{secrets.AMS2MQTT_PRICE_AUTHENTICATION}}"/g' platformio.ini
|
|
sed -i 's/NO_AMS2MQTT_SC_KEY/AMS2MQTT_SC_KEY=\\"${{secrets.AMS2MQTT_SC_KEY}}\\"/g' platformio.ini
|
|
sed -i 's/NO_ENERGY_SPEEDOMETER_USER/ENERGY_SPEEDOMETER_USER=\\"${{secrets.ENERGY_SPEEDOMETER_USER}}\\"/g' platformio.ini
|
|
sed -i 's/NO_ENERGY_SPEEDOMETER_PASS/ENERGY_SPEEDOMETER_PASS=\\"${{secrets.ENERGY_SPEEDOMETER_PASS}}\\"/g' platformio.ini
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install -U platformio css_html_js_minify
|
|
|
|
- name: Set up node
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '19.x'
|
|
- name: Build with node
|
|
run: |
|
|
cd lib/SvelteUi/app
|
|
npm ci
|
|
npm run build
|
|
cd -
|
|
env:
|
|
CI: false
|
|
|
|
- name: PlatformIO lib install
|
|
run: pio lib install
|
|
|
|
- name: Build firmware
|
|
env:
|
|
GITHUB_TAG: v${{ inputs.version }}
|
|
run: pio run -e ${{ inputs.env }}
|
|
|
|
- name: Create zip file
|
|
run: /bin/sh scripts/${{ inputs.env }}/mkzip.sh
|
|
|
|
- name: Upload binary to release
|
|
uses: actions/upload-release-asset@v1
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
upload_url: ${{ inputs.upload_url }}
|
|
asset_path: .pio/build/${{ inputs.env }}/firmware.bin
|
|
asset_name: ams2mqtt-${{ inputs.env }}-${{ inputs.version }}.bin
|
|
asset_content_type: application/octet-stream
|
|
|
|
- name: Upload zip to release
|
|
uses: actions/upload-release-asset@v1
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
upload_url: ${{ inputs.upload_url }}
|
|
asset_path: ${{ inputs.env }}.zip
|
|
asset_name: ams2mqtt-${{ inputs.env }}-${{ inputs.version }}.zip
|
|
asset_content_type: application/zip
|
|
|
|
- name: Create MD5 checksum file
|
|
run: md5sum .pio/build/${{ inputs.env }}/firmware.bin | cut -z -d ' ' -f 1 > firmware.md5
|
|
|
|
- name: Upload binary to S3
|
|
run: aws s3 cp .pio/build/${{ inputs.env }}/firmware.bin s3://${{ secrets.AWS_S3_BUCKET }}/firmware${{ inputs.subfolder }}/ams2mqtt-${{ inputs.env }}-${{ inputs.version }}.bin
|
|
|
|
- name: Upload MD5 checksum to S3
|
|
run: aws s3 cp firmware.md5 s3://${{ secrets.AWS_S3_BUCKET }}/firmware${{ inputs.subfolder }}/ams2mqtt-${{ inputs.env }}-${{ inputs.version }}.md5
|
|
|
|
- name: Upload bootloader to S3
|
|
if: ${{ inputs.is_esp32 }}
|
|
run: aws s3 cp .pio/build/${{ inputs.env }}/bootloader.bin s3://${{ secrets.AWS_S3_BUCKET }}/firmware${{ inputs.subfolder }}/ams2mqtt-${{ inputs.env }}-${{ inputs.version }}-bootloader.bin
|
|
|
|
- name: Upload partition table to S3
|
|
if: ${{ inputs.is_esp32 }}
|
|
run: aws s3 cp .pio/build/${{ inputs.env }}/partitions.bin s3://${{ secrets.AWS_S3_BUCKET }}/firmware${{ inputs.subfolder }}/ams2mqtt-${{ inputs.env }}-${{ inputs.version }}-partitions.bin
|
|
|
|
- name: Upload app0 to S3
|
|
if: ${{ inputs.is_esp32 }}
|
|
run: aws s3 cp ~/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin s3://${{ secrets.AWS_S3_BUCKET }}/firmware${{ inputs.subfolder }}/ams2mqtt-${{ inputs.env }}-${{ inputs.version }}-app0.bin
|