diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e741dfb1..6adce309 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,10 +4,11 @@ name: PlatformIO CI on: workflow_call: inputs: - version: - description: 'Build VERSION in format yymmddb (optional, for nightly builds)' + nightly_build: + description: 'Flag to indicate this is a nightly build' required: false - type: string + type: boolean + default: false jobs: @@ -67,7 +68,7 @@ jobs: - name: Build firmware env: WLED_RELEASE: True - PLATFORMIO_BUILD_FLAGS: ${{ inputs.version && format('-D VERSION={0}', inputs.version) || '' }} + WLED_NIGHTLY_BUILD: ${{ inputs.nightly_build && 'true' || 'false' }} run: pio run -e ${{ matrix.environment }} - name: Rename Bin run: mv -v .pio/build/${{ matrix.environment }}/firmware.bin firmware-${{ matrix.environment }}.bin diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 88b70d11..0a1edd9d 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -8,25 +8,10 @@ on: workflow_dispatch: jobs: - calculate_version: - name: Calculate VERSION - runs-on: ubuntu-latest - outputs: - version: ${{ steps.version.outputs.version }} - steps: - - name: Calculate VERSION - id: version - run: | - # VERSION format: yymmddb (b = daily build number, set to 1 for nightly) - VERSION=$(date -u +"%y%m%d")1 - echo "version=$VERSION" >> $GITHUB_OUTPUT - echo "Calculated VERSION: $VERSION" - wled_build: - needs: calculate_version uses: ./.github/workflows/build.yml with: - version: ${{ needs.calculate_version.outputs.version }} + nightly_build: true nightly: name: Deploy nightly runs-on: ubuntu-latest diff --git a/pio-scripts/set_nightly_version.py b/pio-scripts/set_nightly_version.py new file mode 100644 index 00000000..b069e777 --- /dev/null +++ b/pio-scripts/set_nightly_version.py @@ -0,0 +1,11 @@ +Import('env') +import os +from datetime import datetime, timezone + +# Only set VERSION if this is a nightly build (indicated by environment variable) +if os.environ.get('WLED_NIGHTLY_BUILD') == 'true': + # VERSION format: yymmddb (b = build number, 0 for nightly) + version_code = datetime.now(timezone.utc).strftime("%y%m%d") + "0" + env.Append(BUILD_FLAGS=[f"-DVERSION={version_code}"]) + print(f"Nightly build: Setting VERSION to {version_code}") + diff --git a/platformio.ini b/platformio.ini index 2a5a707a..ebc4ec0a 100644 --- a/platformio.ini +++ b/platformio.ini @@ -224,6 +224,7 @@ ldscript_16m14m = eagle.flash.16m14m.ld [scripts_defaults] extra_scripts = pre:pio-scripts/set_version.py + pre:pio-scripts/set_nightly_version.py pre:pio-scripts/build_ui.py pre:pio-scripts/conditional_usb_mode.py pre:pio-scripts/set_repo.py