Browse Source

github action test

pull/1341/head
lumapu 1 year ago
parent
commit
c9135e06e1
  1. 23
      .github/workflows/compile_development.yml
  2. 187
      scripts/getVersion.py

23
.github/workflows/compile_development.yml

@ -65,6 +65,9 @@ jobs:
- name: Run PlatformIO
run: pio run -d src -e ${{ matrix.variant }}
- name: Rename Firmware
run: python ../scripts/getVersion.py ${{ matrix.variant }} >> $GITHUB_OUTPUT
- name: Create Artifact
uses: actions/upload-artifact@v3
with:
@ -123,12 +126,15 @@ jobs:
- name: Run PlatformIO
run: pio run -d src -e ${{ matrix.variant }}
- name: Rename Firmware
run: python ../scripts/getVersion.py ${{ matrix.variant }} >> $GITHUB_OUTPUT
- name: Create Artifact
uses: actions/upload-artifact@v3
with:
name: ahoydtu_dev
path: |
src/firmware/*
firmware/*
deploy:
needs: [build-en, build-de]
@ -141,19 +147,18 @@ jobs:
uses: actions/download-artifact@master
with:
name: ahoydtu_dev
path: src/firmware/*
path: firmware/*
- name: Rename Binary files
id: rename-binary-files
working-directory: src
run: python ../scripts/getVersion.py >> $GITHUB_OUTPUT
- name: Get Version from code
id: version_name
run: python ../scripts/getVersion.py ${{ matrix.variant }} >> $GITHUB_OUTPUT
- name: Set Version
uses: cschleiden/replace-tokens@v1
with:
files: tools/esp8266/User_Manual.md
env:
VERSION: ${{ steps.rename-binary-files.outputs.name }}
VERSION: ${{ steps.version_name.outputs.name }}
# - name: Create Manifest
# working-directory: src
@ -169,12 +174,12 @@ jobs:
# src/install.html
- name: Rename firmware directory
run: mv src/firmware src/${{ steps.rename-binary-files.outputs.name }}
run: mv src/firmware src/${{ steps.version_name.outputs.name }}
- name: Deploy
uses: nogsantos/scp-deploy@master
with:
src: src/${{ steps.rename-binary-files.outputs.name }}/
src: src/${{ steps.version_name.outputs.name }}/
host: ${{ secrets.FW_SSH_HOST }}
remote: ${{ secrets.FW_SSH_DIR }}/dev
port: ${{ secrets.FW_SSH_PORT }}

187
scripts/getVersion.py

@ -2,6 +2,7 @@ import os
import shutil
import gzip
from datetime import date
import sys
def genOtaBin(path):
arr = []
@ -32,8 +33,8 @@ def gzip_bin(bin_file, gzip_file):
with gzip.open(gzip_file, "wb", compresslevel = 9) as f:
shutil.copyfileobj(fp, f)
def readVersion(path, infile):
f = open(path + infile, "r")
def getVersion(path_define):
f = open(path_define, "r")
lines = f.readlines()
f.close()
@ -49,159 +50,43 @@ def readVersion(path, infile):
version += line[p+13:].rstrip() + "."
versionnumber += line[p+13:].rstrip() + "."
os.mkdir(path + "firmware/")
os.mkdir(path + "firmware/ESP8266/")
os.mkdir(path + "firmware/ESP8285/")
os.mkdir(path + "firmware/ESP32/")
os.mkdir(path + "firmware/ESP32-S2/")
os.mkdir(path + "firmware/ESP32-S3/")
os.mkdir(path + "firmware/ESP32-C3/")
os.mkdir(path + "firmware/ESP32-S3-ETH/")
return [version, versionnumber]
def renameFw(path_define, env):
version = getVersion(path_define)[0]
os.mkdir("firmware/")
fwDir = ""
if env[:7] == "esp8266":
fwDir = "ESP8266/"
elif env[:7] == "esp8285":
fwDir = "ESP8285/"
elif env[:7] == "esp32-w":
fwDir = "ESP32/"
elif env[:8] == "esp32-s2":
fwDir = "ESP32-S2/"
elif env[:4] == "open":
fwDir = "ESP32-S3/"
elif env[:8] == "esp32-c3":
fwDir = "ESP32-C3/"
os.mkdir("firmware/" + fwDir)
sha = os.getenv("SHA",default="sha")
## ENGLISH VERSIONS
versionout = version[:-1] + "_" + sha + "_esp8266.bin"
src = path + ".pio/build/esp8266/firmware.bin"
dst = path + "firmware/ESP8266/" + versionout
os.rename(src, dst)
dst = "firmware/" + fwDir
fname = version[:-1] + "_" + sha + "_" + env + ".bin"
versionout = version[:-1] + "_" + sha + "_esp8266_prometheus.bin"
src = path + ".pio/build/esp8266-prometheus/firmware.bin"
dst = path + "firmware/ESP8266/" + versionout
os.rename(src, dst)
os.rename(".pio/build/" + env + "/firmware.bin", dst + fname)
versionout = version[:-1] + "_" + sha + "_esp8285.bin"
src = path + ".pio/build/esp8285/firmware.bin"
dst = path + "firmware/ESP8285/" + versionout
os.rename(src, dst)
gzip_bin(dst, dst + ".gz")
versionout = version[:-1] + "_" + sha + "_esp32.bin"
src = path + ".pio/build/esp32-wroom32/firmware.bin"
dst = path + "firmware/ESP32/" + versionout
os.rename(src, dst)
versionout = version[:-1] + "_" + sha + "_esp32_prometheus.bin"
src = path + ".pio/build/esp32-wroom32-prometheus/firmware.bin"
dst = path + "firmware/ESP32/" + versionout
os.rename(src, dst)
versionout = version[:-1] + "_" + sha + "_esp32_ethernet.bin"
src = path + ".pio/build/esp32-wroom32-ethernet/firmware.bin"
dst = path + "firmware/ESP32/" + versionout
os.rename(src, dst)
versionout = version[:-1] + "_" + sha + "_esp32s2-mini.bin"
src = path + ".pio/build/esp32-s2-mini/firmware.bin"
dst = path + "firmware/ESP32-S2/" + versionout
os.rename(src, dst)
versionout = version[:-1] + "_" + sha + "_esp32c3-mini.bin"
src = path + ".pio/build/esp32-c3-mini/firmware.bin"
dst = path + "firmware/ESP32-C3/" + versionout
os.rename(src, dst)
versionout = version[:-1] + "_" + sha + "_esp32s3.bin"
src = path + ".pio/build/opendtufusion/firmware.bin"
dst = path + "firmware/ESP32-S3/" + versionout
os.rename(src, dst)
versionout = version[:-1] + "_" + sha + "_esp32s3_ethernet.bin"
src = path + ".pio/build/opendtufusion-ethernet/firmware.bin"
dst = path + "firmware/ESP32-S3-ETH/" + versionout
os.rename(src, dst)
## GERMAN VERSIONS
versionout = version[:-1] + "_" + sha + "_esp8266-de.bin"
src = path + ".pio/build/esp8266-de/firmware.bin"
dst = path + "firmware/ESP8266/" + versionout
os.rename(src, dst)
versionout = version[:-1] + "_" + sha + "_esp8266_prometheus-de.bin"
src = path + ".pio/build/esp8266-prometheus-de/firmware.bin"
dst = path + "firmware/ESP8266/" + versionout
os.rename(src, dst)
versionout = version[:-1] + "_" + sha + "_esp8285-de.bin"
src = path + ".pio/build/esp8285-de/firmware.bin"
dst = path + "firmware/ESP8285/" + versionout
os.rename(src, dst)
gzip_bin(dst, dst + ".gz")
versionout = version[:-1] + "_" + sha + "_esp32-de.bin"
src = path + ".pio/build/esp32-wroom32-de/firmware.bin"
dst = path + "firmware/ESP32/" + versionout
os.rename(src, dst)
versionout = version[:-1] + "_" + sha + "_esp32_prometheus-de.bin"
src = path + ".pio/build/esp32-wroom32-prometheus-de/firmware.bin"
dst = path + "firmware/ESP32/" + versionout
os.rename(src, dst)
versionout = version[:-1] + "_" + sha + "_esp32_ethernet-de.bin"
src = path + ".pio/build/esp32-wroom32-ethernet-de/firmware.bin"
dst = path + "firmware/ESP32/" + versionout
os.rename(src, dst)
versionout = version[:-1] + "_" + sha + "_esp32s2-mini-de.bin"
src = path + ".pio/build/esp32-s2-mini-de/firmware.bin"
dst = path + "firmware/ESP32-S2/" + versionout
os.rename(src, dst)
versionout = version[:-1] + "_" + sha + "_esp32c3-mini-de.bin"
src = path + ".pio/build/esp32-c3-mini-de/firmware.bin"
dst = path + "firmware/ESP32-C3/" + versionout
os.rename(src, dst)
versionout = version[:-1] + "_" + sha + "_esp32s3-de.bin"
src = path + ".pio/build/opendtufusion-de/firmware.bin"
dst = path + "firmware/ESP32-S3/" + versionout
os.rename(src, dst)
versionout = version[:-1] + "_" + sha + "_esp32s3_ethernet-de.bin"
src = path + ".pio/build/opendtufusion-ethernet-de/firmware.bin"
dst = path + "firmware/ESP32-S3-ETH/" + versionout
os.rename(src, dst)
## BOOTLOADER AND PARTITIONS
# other ESP32 bin files
src = path + ".pio/build/esp32-wroom32/"
dst = path + "firmware/ESP32/"
os.rename(src + "bootloader.bin", dst + "bootloader.bin")
os.rename(src + "partitions.bin", dst + "partitions.bin")
genOtaBin(dst)
# other ESP32-S2 bin files
src = path + ".pio/build/esp32-s2-mini/"
dst = path + "firmware/ESP32-S2/"
os.rename(src + "bootloader.bin", dst + "bootloader.bin")
os.rename(src + "partitions.bin", dst + "partitions.bin")
genOtaBin(dst)
# other ESP32-C3 bin files
src = path + ".pio/build/esp32-c3-mini/"
dst = path + "firmware/ESP32-C3/"
os.rename(src + "bootloader.bin", dst + "bootloader.bin")
os.rename(src + "partitions.bin", dst + "partitions.bin")
genOtaBin(dst)
# other ESP32-S3 bin files
src = path + ".pio/build/opendtufusion/"
dst = path + "firmware/ESP32-S3/"
os.rename(src + "bootloader.bin", dst + "bootloader.bin")
os.rename(src + "partitions.bin", dst + "partitions.bin")
if env[:5] == "esp32":
os.rename(".pio/build/" + env + "/bootloader.bin", dst + "bootloader.bin")
os.rename(".pio/build/" + env + "/partitions.bin", dst + "partitions.bin")
genOtaBin(dst)
# other ESP32-S3-Eth bin files
src = path + ".pio/build/opendtufusion-ethernet/"
dst = path + "firmware/ESP32-S3-ETH/"
os.rename(src + "bootloader.bin", dst + "bootloader.bin")
os.rename(src + "partitions.bin", dst + "partitions.bin")
genOtaBin(dst)
os.rename("../scripts/gh-action-dev-build-flash.html", path + "install.html")
print("name=" + versionnumber[:-1] )
if env[:7] == "esp8285":
gzip_bin(dst + fname, dst + fname[:-4] + ".gz")
readVersion("", "defines.h")
if len(sys.argv) == 1:
print("name=" + getVersion("src/defines.h")[1][:-1])
else:
# arg1: environment
renameFw("src/defines.h", sys.argv[1])

Loading…
Cancel
Save