Skip to content

build-for-release

build-for-release #12

# Workflow that builds the firmware, and adds the binary to the ./Binaries folder, ready for release.
name: build-for-release
# Controls when the workflow will run
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
branches:
env:
FILENAME_PREFIX: OpenLog_Artemis
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@main
- name: Extract branch name
run: echo "BRANCH=${{github.ref_name}}" >> $GITHUB_ENV
- name: Get firmware version 1
run: |
echo "firmwareMajor=$(grep -Po "(?<=FIRMWARE_VERSION_MAJOR = )([0-9])*(?=;$)" ./Firmware/${{ env.FILENAME_PREFIX }}/${{ env.FILENAME_PREFIX }}.ino)" >> "$GITHUB_ENV"
echo "firmwareMinor=$(grep -Po "(?<=FIRMWARE_VERSION_MINOR = )([0-9])*(?=;$)" ./Firmware/${{ env.FILENAME_PREFIX }}/${{ env.FILENAME_PREFIX }}.ino)" >> "$GITHUB_ENV"
- name: Get firmware version 2
run: |
echo "firmwareMajorMinor=-V10-v${{ env.firmwareMajor }}${{ env.firmwareMinor }}" >> "$GITHUB_ENV"
echo "firmwareMajorMinorX04=-X04-v${{ env.firmwareMajor }}${{ env.firmwareMinor }}" >> "$GITHUB_ENV"
- name: Run Dockerfile and copy files
run: |
cd ./Firmware
docker build -t openlog_artemis_image --no-cache .
docker create --name=openlog_artemis_container openlog_artemis_image:latest
mkdir ./build
docker cp openlog_artemis_container:/${{ env.FILENAME_PREFIX }}.ino.bin ./build
docker container rm openlog_artemis_container
- name: Rename binary
run: |
cd ./Firmware/build/
mv ${{ env.FILENAME_PREFIX }}.ino.bin ${{ env.FILENAME_PREFIX }}${{ env.firmwareMajorMinor }}.bin
echo "targetBinary=./Firmware/build/${{ env.FILENAME_PREFIX }}${{ env.firmwareMajorMinor }}.bin" >> "$GITHUB_ENV"
- name: Move binary
run: mv ${{ env.targetBinary }} ./Binaries
- uses: actions-js/push@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ env.BRANCH }}
directory: './Binaries'
message: 'Pushing new firmware binary'