-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'publish-action' into 'master'
Publish action See merge request MSO-SW/unified-prototyping-toolkit/upt-core!27
- Loading branch information
Showing
4 changed files
with
86 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.") |