From f74b2eb84045a1e6b861124674896f4ea22f48bb Mon Sep 17 00:00:00 2001 From: Quentin Fisch Date: Thu, 8 Feb 2024 19:46:01 +0100 Subject: [PATCH 1/5] added gh action template for PIO publish --- .../workflows/platformio_publish_template.yml | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflows/platformio_publish_template.yml diff --git a/.github/workflows/platformio_publish_template.yml b/.github/workflows/platformio_publish_template.yml new file mode 100644 index 0000000..f589474 --- /dev/null +++ b/.github/workflows/platformio_publish_template.yml @@ -0,0 +1,53 @@ +name: PlatformIO Publish + +on: + workflow_call: + inputs: + pkg-owner: + type: string + description: The user/org that will be the owner of the published package + default: "sensirion" + secrets: + pio-registry-token: + description: PlatformIO Token used to login + required: true + +jobs: + platformio-publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/cache@v3 + with: + path: | + ~/.cache/pip + ~/.platformio/.cache + key: ${{ runner.os }}-pio + - uses: actions/setup-python@v4 + with: + python-version: "3.9" + - name: Install PlatformIO Core + run: pip install --upgrade platformio + - name: Recreate tmp folder + run: | + if [ -d ./tmp/ ]; then rm -Rf ./tmp/; fi + mkdir ./tmp/ + - name: Select relevant resource to package + run: | + cp -r examples tmp + cp -r src tmp + cp -r py_scripts tmp + cp CHANGELOG.md tmp + cp library.properties tmp + cp LICENSE tmp + cp platformio.ini tmp + cp README.md tmp + + - name: Create library package + run: pio pkg pack tmp + - name: Login into PlatformIO + run: pio account login + env: + PLATFORMIO_AUTH_TOKEN: ${{ secrets.pio-registry-token }} + # - name: Run 'pio pkg publish' + # run: pio pkg publish --owner ${{ inputs.pkg-owner }} --no-interactive ./*.tar.gz From 710ca66325cd3b1da896e5f5b9537bfce9ac8750 Mon Sep 17 00:00:00 2001 From: Quentin Fisch Date: Thu, 8 Feb 2024 19:46:27 +0100 Subject: [PATCH 2/5] moved py script --- platformio.ini | 2 +- make_cpp_files.py => py_scripts/make_cpp_files.py | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename make_cpp_files.py => py_scripts/make_cpp_files.py (100%) diff --git a/platformio.ini b/platformio.ini index 5ac62c4..aaea325 100644 --- a/platformio.ini +++ b/platformio.ini @@ -16,7 +16,7 @@ framework = arduino platform = espressif32 board = lilygo-t-display-s3 extra_scripts = - pre:make_cpp_files.py + pre:py_scripts/make_cpp_files.py monitor_speed = 115200 lib_ldf_mode = deep lib_extra_dirs = ${PROJECT_DIR}/src/ diff --git a/make_cpp_files.py b/py_scripts/make_cpp_files.py similarity index 100% rename from make_cpp_files.py rename to py_scripts/make_cpp_files.py From ba30b1c8e326cdd985f1bf3d8bb8744c10ed28ff Mon Sep 17 00:00:00 2001 From: Quentin Fisch Date: Thu, 8 Feb 2024 19:55:24 +0100 Subject: [PATCH 3/5] added artifact in publish workflow and input 'should-publish' --- .../workflows/platformio_publish_template.yml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/platformio_publish_template.yml b/.github/workflows/platformio_publish_template.yml index f589474..f1ddd3b 100644 --- a/.github/workflows/platformio_publish_template.yml +++ b/.github/workflows/platformio_publish_template.yml @@ -7,6 +7,10 @@ on: type: string description: The user/org that will be the owner of the published package default: "sensirion" + should-publish: + type: boolean + description: Should the package be published to the registry + default: false secrets: pio-registry-token: description: PlatformIO Token used to login @@ -42,12 +46,18 @@ jobs: cp LICENSE tmp cp platformio.ini tmp cp README.md tmp - - name: Create library package run: pio pkg pack tmp + - name: Upload package archive + uses: actions/upload-artifact@v4 + with: + name: pio-library-archive + path: /*.tar.gz + retention-days: 2 - name: Login into PlatformIO run: pio account login env: PLATFORMIO_AUTH_TOKEN: ${{ secrets.pio-registry-token }} - # - name: Run 'pio pkg publish' - # run: pio pkg publish --owner ${{ inputs.pkg-owner }} --no-interactive ./*.tar.gz + - name: Run 'pio pkg publish' + if: ${{ inputs.should-publish }} + run: pio pkg publish --owner ${{ inputs.pkg-owner }} --no-interactive ./*.tar.gz From 5493cbecd1cb5ee71f19e2edefa829300425e492 Mon Sep 17 00:00:00 2001 From: Quentin Fisch Date: Fri, 9 Feb 2024 10:28:29 +0100 Subject: [PATCH 4/5] made the cpp file script platform independant --- py_scripts/make_cpp_files.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/py_scripts/make_cpp_files.py b/py_scripts/make_cpp_files.py index 389c629..405468d 100644 --- a/py_scripts/make_cpp_files.py +++ b/py_scripts/make_cpp_files.py @@ -1,5 +1,16 @@ import os +import shutil + +ARDUINO_FILE_EXTENSION = ".ino" +TARGET_FILE_EXTENSION = ".cpp" +EXAMPLE_FOLDER = "examples" # Create a .cpp file for all the .ino files in the examples dir (CAUTION: will overwrite existing) print("PRE_SCRIPT: Copying .ino file contents to .cpp files.") -os.system(f'find examples -type f -name "*.ino" -exec bash -c \'for file; do cp "$file" "$(dirname "$file")/$(basename "$file" .ino).cpp"; done\' _ {{}} +') +for e in os.listdir(EXAMPLE_FOLDER): + if os.path.isdir(f"{EXAMPLE_FOLDER}/{e}") and os.path.isfile(f"{EXAMPLE_FOLDER}/{e}/{e}{ARDUINO_FILE_EXTENSION}"): + arduino_file =f"{EXAMPLE_FOLDER}/{e}/{e}{ARDUINO_FILE_EXTENSION}" + cpp_file = f"{EXAMPLE_FOLDER}/{e}/{e}{TARGET_FILE_EXTENSION}" + shutil.copyfile(arduino_file, cpp_file) + print(f'\tcopied {arduino_file} to {cpp_file}') +print("\t>> Done.") From cfa36531cd4b42e0fff8c9f1390050c6fe4bf762 Mon Sep 17 00:00:00 2001 From: Quentin Fisch Date: Fri, 9 Feb 2024 11:13:29 +0100 Subject: [PATCH 5/5] removed Sensirion prefix for PIO lib --- .github/workflows/platformio_publish_template.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/platformio_publish_template.yml b/.github/workflows/platformio_publish_template.yml index f1ddd3b..cc6b11a 100644 --- a/.github/workflows/platformio_publish_template.yml +++ b/.github/workflows/platformio_publish_template.yml @@ -46,6 +46,12 @@ jobs: cp LICENSE tmp cp platformio.ini tmp cp README.md tmp + - name: Remove 'Sensirion' from lib name + run: | + nameline=$(head -n 1 tmp/library.properties) + toremove='Sensirion ' + pioname="${nameline/$toremove/}" + sed -i "1s/.*/$pioname/" tmp/library.properties - name: Create library package run: pio pkg pack tmp - name: Upload package archive