Skip to content

Merge pull request #123 from basmeerman/feature/basmeerman-update-row #78

Merge pull request #123 from basmeerman/feature/basmeerman-update-row

Merge pull request #123 from basmeerman/feature/basmeerman-update-row #78

Workflow file for this run

name: PlatformIO CI
on:
workflow_call:
inputs:
major:
required: true
type: string
minor:
required: true
type: string
patch:
required: true
type: string
prerelease:
required: false
type: string
outputs:
artifact:
description: "The first output string"
value: ${{ jobs.build.outputs.artifact }}
push:
branches:
- master
- release/*
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Get current branch
id: branch
run: echo "branch=${GITHUB_REF##*/}" >> $GITHUB_OUTPUT
- name: Get current datetime
id: datetime
run: echo "datetime=$(date +'%Y%m%dT%H%M%S')" >> $GITHUB_OUTPUT
- name: Get current time
id: time
run: echo "time=$(date +'%H%M%S')" >> $GITHUB_OUTPUT
- name: Get version
id: version
shell: bash
run: |
if [ -z "${{ inputs.major }}" ]
then
echo "version=${{ steps.time.outputs.time }}" >> $GITHUB_OUTPUT
else
if [ -z "${{ inputs.prerelease }}" ]
then
echo "version=${{ inputs.major }}.${{ inputs.minor }}.${{ inputs.patch }}" >> $GITHUB_OUTPUT
else
echo "version=${{ inputs.major }}.${{ inputs.minor }}.${{ inputs.patch }}-${{ inputs.prerelease }}" >> $GITHUB_OUTPUT
fi
fi
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Cache pip
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
with:
path: ~/.cache/pip
key: '${{ runner.os }}-pip-${{ hashFiles(''**/requirements.txt'') }}'
restore-keys: |
${{ runner.os }}-pip-
- name: Cache PlatformIO
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
with:
path: ~/.platformio
key: '${{ runner.os }}-pio-${{ hashFiles(''SmartEVSE-3/platformio.ini'') }}'
restore-keys: |
${{ runner.os }}-pio-
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: '3.10'
- name: Install PlatformIO
run: |
python -m pip install --upgrade pip
pip install --upgrade platformio
- name: Build normal version
run: |
PLATFORMIO_BUILD_FLAGS='-DVERSION=\"v${{ steps.version.outputs.version }}\" -DDBG=0' pio run -d SmartEVSE-3/
mkdir -p ./SmartEVSE-3/distribution
- name: Sign normal version
env:
super_secret: ${{ secrets.SECRET_RSA_KEY }}
run: |
if [ -z "$super_secret" ]; then
echo "Signing key not available, skipping firmware signing"
exit 0
fi
secret_file=$(mktemp)
echo "$super_secret" > "$secret_file"
openssl dgst -sign "$secret_file" -keyform PEM -sha256 -out firmware.sign -binary ./SmartEVSE-3/.pio/build/release/firmware.bin
cat firmware.sign ./SmartEVSE-3/.pio/build/release/firmware.bin > ./SmartEVSE-3/.pio/build/release/firmware.signed.bin
rm -f "$secret_file"
- name: Collect normal build artifacts
run: mv ./SmartEVSE-3/.pio/build/release/*.bin ./SmartEVSE-3/distribution
- name: Build debug version
run: |
PLATFORMIO_BUILD_FLAGS='-DVERSION=\"v${{ steps.version.outputs.version }}\" -DDBG=1' pio run -d SmartEVSE-3/
- name: Sign debug version
env:
super_secret: ${{ secrets.SECRET_RSA_KEY }}
run: |
if [ -z "$super_secret" ]; then
echo "Signing key not available, skipping firmware signing"
exit 0
fi
secret_file=$(mktemp)
echo "$super_secret" > "$secret_file"
openssl dgst -sign "$secret_file" -keyform PEM -sha256 -out firmware.sign -binary ./SmartEVSE-3/.pio/build/release/firmware.bin
cat firmware.sign ./SmartEVSE-3/.pio/build/release/firmware.bin > ./SmartEVSE-3/.pio/build/release/firmware.signed.bin
rm -f "$secret_file"
- name: Collect debug build artifacts
run: |
mv ./SmartEVSE-3/.pio/build/release/firmware.bin ./SmartEVSE-3/distribution/firmware.debug.bin
if [ -f ./SmartEVSE-3/.pio/build/release/firmware.signed.bin ]; then
mv ./SmartEVSE-3/.pio/build/release/firmware.signed.bin ./SmartEVSE-3/distribution/firmware.debug.signed.bin
fi
cp -a ./SmartEVSE-3/HowToFlash.txt ./SmartEVSE-3/distribution
# Combined upload for all artifacts using v4
- name: Upload all artifacts
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: dists_zip
path: |
./SmartEVSE-3/distribution/*
retention-days: 10
compression-level: 6
overwrite: true
outputs:
artifact: dists_zip