Skip to content

Commit

Permalink
Merge pull request #538 from KipK/build_version
Browse files Browse the repository at this point in the history
dynamically set build version using current git tag/shorthash
  • Loading branch information
glynhudson authored Mar 29, 2023
2 parents 578e19c + db9cc5a commit 610868d
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 39 deletions.
48 changes: 34 additions & 14 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

name: Build/Release OpenEVSE

permissions:
contents: write

on:
workflow_dispatch:
inputs:
Expand All @@ -13,10 +16,12 @@ on:
required: true
description: The branch/tag for the v2 UI
default: master

push:
branches:
- master
tags:
- 'v*'
pull_request:

jobs:
Expand All @@ -28,7 +33,7 @@ jobs:

- name: Dump the event
run: cat $GITHUB_EVENT_PATH

- name: Dump github.ref_name
run: echo "github.ref_name = '${{ github.ref_name }}'"

Expand All @@ -54,11 +59,11 @@ jobs:
- openevse_esp32-poe-iso
- openevse_esp32-heltec-wifi-lora-v2
gui:
- name: dev_gui-v1
- name: gui-v1
repo: OpenEVSE/openevse_wifi_gui
build_flags: ""
ref: ${{ inputs.v1_ref }}
- name: dev_gui-v2
- name: gui-v2
repo: KipK/openevse-gui-v2
build_flags: "-D DISABLE_WIFI_PORTAL -D WEB_SERVER_ROOT_PAGE_INDEX"
ref: ${{ inputs.v2_ref }}
Expand All @@ -68,13 +73,6 @@ jobs:

- uses: actions/checkout@v3

# - name: Temp checkout latest OpenEVSE lib
# uses: actions/checkout@v3
# with:
# repository: jeremypoulter/OpenEVSE_Lib
# ref: openevse_wifi_timer_apis
# path: lib/OpenEVSE

- name: Checkout GUI
uses: actions/checkout@v3
with:
Expand Down Expand Up @@ -137,7 +135,7 @@ jobs:
release:
runs-on: ubuntu-latest
needs: build
if: github.ref_name == 'master' || github.ref_name == 'build_v2_gui' || github.head_ref == 'build_v2_gui'
if: github.ref_name == 'master' || startsWith(github.ref_name, 'v')

steps:
- name: Download the built assets
Expand All @@ -155,11 +153,33 @@ jobs:
done
- name: Upload assets to latest release
if: github.ref_name == 'master'
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "${{ github.ref_name == 'master' && 'latest' || 'v2_gui' }}"
automatic_release_tag: latest
prerelease: true
title: Development Build
files: |
*gui-v1.bin
- name: Upload assets to the v2 GUI release
if: github.ref_name == 'master'
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: v2_gui
prerelease: true
title: V2 GUI pre-release
files: |
*gui-v2.bin
- name: Upload assets to release
if: startsWith(github.ref_name, 'v')
uses: "softprops/action-gh-release@v1"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: true
title: "${{ github.ref_name == 'master' && 'Development Build' || 'V2 GUI pre-release' }}"
title: "${{ github.ref_name }}"
files: |
*.bin
10 changes: 5 additions & 5 deletions .github/workflows/release_validation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Set up Node JS
uses: actions/setup-node@v3
with:
node-version: '12'
node-version: '16'

- name: Install dependencies
run: |
Expand Down Expand Up @@ -53,14 +53,14 @@ jobs:

- name: Retrieve the version number(s)
run: |
TAG_VERSION=$(sed "s/^v//" <<< $GITHUB_REF_NAME)
CODE_VERSION=$(grep BUILD_TAG platformio.ini | awk -F= '{print $NF}')
TAG_VERSION=$GITHUB_REF_NAME
CODE_VERSION=$(git describe --tags)
echo TAG_VERSION=$TAG_VERSION >> $GITHUB_ENV
echo CODE_VERSION=$CODE_VERSION >> $GITHUB_ENV
- name: Check the version numberis semver compliant
- name: Check the version number is semver compliant
run: |
if ! [[ $TAG_VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-z]*[0-9]+)?$ ]]; then
if ! [[ $TAG_VERSION =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[a-z]*[0-9]+)?$ ]]; then
echo "ERROR: The version number is not semver compliant"
exit 1
fi
Expand Down
11 changes: 5 additions & 6 deletions docs/process.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,18 @@ For releases and PR approval the builds are built using the [Build/Release OpenE

1. Ensure GitHub actions are complete and green
[![Build/Release OpenEVSE](https://github.com/OpenEVSE/ESP32_WiFi_V4.x/actions/workflows/build.yaml/badge.svg)](https://github.com/OpenEVSE/ESP32_WiFi_V4.x/actions/workflows/build.yaml)
1. Check the [version number](https://semver.org/) is correct
1. Go to the latest [Development Build](https://github.com/OpenEVSE/ESP32_WiFi_V4.x/releases/tag/latest) release
1. Edit the release
1. Change the tag from latest to the [version number](https://semver.org/), for example: `v1.0.0`
1. Change the branch to `latest`, is not automatically filled in so have to type the name in. Will show the appropriate commit hash on pressing enter
1. Enter the version number as the release name, for example: `v1.0.0`
1. Create a new [GitHub release](https://github.com/OpenEVSE/ESP32_WiFi_V4.x/releases/new) entering the tag name as the new [version number](https://semver.org/), for example: `v1.0.0`
1. Add the release notes, a good start is to use the `Auto-Generated Release Notes` and edit as needed
1. Select the `Pre-release` checkbox
1. Click `Publish release`
1. The GitHub build workflow will generate the binaries and upload them to the release
1. Remove any unwanted binaries, need at least:
- `openevse_esp32-gateway-e.bin`
- `openevse_huzzah32.bin`
- `openevse_wifi_v1.bin`
- `openevse_esp-wrover-kit`
- `openevse_nodemcu-32s`
1. Test the uploaded binaries
1. Unselect the `Pre-release` checkbox
1. Click `Update release`
1. Ensure the release validation action is green
Expand Down
18 changes: 4 additions & 14 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ data_dir = src/data
default_envs = openevse_wifi_v1

[common]
version = -D BUILD_TAG=4.1.8
lib_deps =
bblanchon/[email protected]
jeremypoulter/[email protected]
Expand All @@ -42,7 +41,9 @@ lib_deps =
matth-x/[email protected]
matth-x/[email protected]
lib_ignore = WebSockets ; ArduinoOcpp: don't compile built-in WS library
extra_scripts = scripts/extra_script.py
extra_scripts =
pre:scripts/auto_fw_version.py
scripts/extra_script.py
debug_flags =
-ggdb
-D ENABLE_DEBUG
Expand Down Expand Up @@ -116,8 +117,7 @@ platform = [email protected]
framework = arduino
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
build_flags =
${common.build_flags}
build_flags = ${common.build_flags}
#upload_port = openevse.local
upload_speed = 921600
extra_scripts = ${common.extra_scripts}
Expand All @@ -134,7 +134,6 @@ monitor_filters =
board = nodemcu-32s
build_flags =
${common.build_flags}
${common.version}.dev
${common.src_build_flags}
${common.debug_flags}
-D WIFI_LED=2
Expand All @@ -148,7 +147,6 @@ lib_deps =
${common.neopixel_lib}
build_flags =
${common.build_flags}
${common.version}.dev
${common.src_build_flags}
${common.debug_flags}
-D WIFI_BUTTON=2
Expand Down Expand Up @@ -179,7 +177,6 @@ platform = espressif32
[env:openevse_huzzah32_dev]
board = featheresp32
build_flags =
${common.version}.dev
${common.build_flags}
${common.src_build_flags}
${common.debug_flags}
Expand All @@ -194,7 +191,6 @@ build_flags =
board = featheresp32
build_flags =
${common.build_flags}
${common.version}
${common.src_build_flags}
-D WIFI_LED=13
-D WIFI_LED_ON_STATE=HIGH
Expand All @@ -207,7 +203,6 @@ build_flags =
board = featheresp32
build_flags =
${common.build_flags}
${common.version}.dev
${common.src_build_flags}
${common.debug_flags}
-D WIFI_LED=LED_BUILTIN
Expand All @@ -223,7 +218,6 @@ lib_deps =
adafruit/Adafruit MCP9808 Library @ 1.1.2
build_flags =
${common.build_flags}
${common.version}
${common.src_build_flags}
${common.debug_flags}
-D NEO_PIXEL_PIN=17
Expand All @@ -245,7 +239,6 @@ upload_command = curl -F firmware=@$SOURCE http://$UPLOAD_PORT/update --progress
board = esp32-gateway
build_flags =
${common.build_flags}
${common.version}
${common.src_build_flags}
-D WIFI_LED=33
-D WIFI_LED_ON_STATE=HIGH
Expand All @@ -262,7 +255,6 @@ build_flags =
board = esp32-gateway
build_flags =
${common.build_flags}
${common.version}
${common.src_build_flags}
-D WIFI_LED=33
-D WIFI_LED_ON_STATE=HIGH
Expand Down Expand Up @@ -306,7 +298,6 @@ board_build.partitions = ${common.build_partitions_debug}
board = esp32-poe-iso
build_flags =
${common.build_flags}
${common.version}
${common.src_build_flags}
-D WIFI_BUTTON=34
-D WIFI_BUTTON_PRESSED_STATE=LOW
Expand All @@ -321,7 +312,6 @@ board = heltec_wifi_lora_32_V2
build_flags =
${common.build_flags}
${common.src_build_flags}
${common.version}.dev
-D DEBUG_PORT=Serial
-D WIFI_LED=25
-D WIFI_LED_ON_STATE=HIGH
Expand Down
18 changes: 18 additions & 0 deletions scripts/auto_fw_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import subprocess
import os

Import("env")



def get_build_flag():
#ret = subprocess.run(["git", "describe"], stdout=subprocess.PIPE, text=True) #Uses only annotated tags
ret = subprocess.run(["git", "describe", "--tags"], stdout=subprocess.PIPE, text=True) #Uses any tags
build_version = ret.stdout.strip()
build_flag = "-D BUILD_TAG=" + build_version
print ("Firmware Revision: " + build_flag)
return (build_flag)

env.Append(
BUILD_FLAGS=[get_build_flag()]
)

0 comments on commit 610868d

Please sign in to comment.