Skip to content

Commit

Permalink
Merge branch 'publish-action' into 'master'
Browse files Browse the repository at this point in the history
Publish action

See merge request MSO-SW/unified-prototyping-toolkit/upt-core!27
  • Loading branch information
qfisch committed Feb 9, 2024
2 parents 4042a71 + cfa3653 commit 900d33b
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 6 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/platformio_publish_template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
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"
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
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: 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
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'
if: ${{ inputs.should-publish }}
run: pio pkg publish --owner ${{ inputs.pkg-owner }} --no-interactive ./*.tar.gz
5 changes: 0 additions & 5 deletions make_cpp_files.py

This file was deleted.

2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
16 changes: 16 additions & 0 deletions py_scripts/make_cpp_files.py
Original file line number Diff line number Diff line change
@@ -0,0 +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.")
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.")

0 comments on commit 900d33b

Please sign in to comment.