Skip to content

Commit

Permalink
Merge pull request #2 from Sensirion/publish-workflow
Browse files Browse the repository at this point in the history
Added publish workflow
  • Loading branch information
qfisch authored Feb 9, 2024
2 parents 115d07b + 76248dd commit 542ff19
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 79 deletions.
60 changes: 30 additions & 30 deletions .github/workflows/platformio_build_template.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
name: PlatformIO Build

on:
workflow_call:
inputs:
pio-environment-list:
type: string
default: '["usage_example"]'
pio-ini-location:
type: string
default: '.'
workflow_call:
inputs:
pio-environment-list:
type: string
default: '["usage_example"]'
pio-ini-location:
type: string
default: "."

jobs:
platformio-build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
environment: ${{ fromJSON(inputs.pio-environment-list) }}
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: Build examples with 'pio run'
working-directory: ${{ inputs.pio-ini-location }}
run: pio run -e ${{ matrix.environment }}
platformio-build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
environment: ${{ fromJSON(inputs.pio-environment-list) }}
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.cache/pip
~/.platformio/.cache
key: ${{ runner.os }}-pio
- uses: actions/setup-python@v5
with:
python-version: "3.9"
- name: Install PlatformIO Core
run: pip install --upgrade platformio
- name: Build examples with 'pio run'
working-directory: ${{ inputs.pio-ini-location }}
run: pio run -e ${{ matrix.environment }}
58 changes: 29 additions & 29 deletions .github/workflows/platformio_check_template.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
name: PlatformIO Check

on:
workflow_call:
inputs:
pio-environment-list:
type: string
default: '["usage_example"]'
pio-ini-location:
type: string
default: '.'
workflow_call:
inputs:
pio-environment-list:
type: string
default: '["usage_example"]'
pio-ini-location:
type: string
default: "."

jobs:
platformio-check:
runs-on: ubuntu-latest
strategy:
matrix:
environment: ${{ fromJSON(inputs.pio-environment-list) }}
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: Run 'pio check'
working-directory: ${{ inputs.pio-ini-location }}
run: pio check -e ${{ matrix.environment }}
platformio-check:
runs-on: ubuntu-latest
strategy:
matrix:
environment: ${{ fromJSON(inputs.pio-environment-list) }}
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.cache/pip
~/.platformio/.cache
key: ${{ runner.os }}-pio
- uses: actions/setup-python@v5
with:
python-version: "3.9"
- name: Install PlatformIO Core
run: pip install --upgrade platformio
- name: Run 'pio check'
working-directory: ${{ inputs.pio-ini-location }}
run: pio check -e ${{ matrix.environment }}
9 changes: 5 additions & 4 deletions .github/workflows/platformio_publish_template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ on:
secrets:
pio-registry-token:
description: PlatformIO Token used to login
required: true
required: false

jobs:
platformio-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.cache/pip
~/.platformio/.cache
key: ${{ runner.os }}-pio
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: "3.9"
- name: Install PlatformIO Core
Expand Down Expand Up @@ -61,6 +61,7 @@ jobs:
path: /*.tar.gz
retention-days: 2
- name: Login into PlatformIO
if: ${{ inputs.should-publish }}
run: pio account login
env:
PLATFORMIO_AUTH_TOKEN: ${{ secrets.pio-registry-token }}
Expand Down
48 changes: 32 additions & 16 deletions .github/workflows/platformio_workflow.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,39 @@
name: PIO Lib

on:
pull_request:
branches:
- main
push:
branches:
- main
pull_request:
branches:
- master
push:
branches:
- master
tags:
- "[0-9]+.[0-9]+.[0-9]+"

jobs:
PlatformIO-Check:
uses: ./.github/workflows/platformio_check_template.yml
with:
pio-environment-list: '["esp32dev"]'
pio-ini-location: "./examples/exampleUsage"
PlatformIO-Check:
uses: ./.github/workflows/platformio_check_template.yml
with:
pio-environment-list: '["ble_example", "basicUsage"]'

PlatformIO-Build:
uses: ./.github/workflows/platformio_build_template.yml
with:
pio-environment-list: '["esp32dev"]'
pio-ini-location: "./examples/exampleUsage"
PlatformIO-Build:
uses: ./.github/workflows/platformio_build_template.yml
needs: PlatformIO-Check
with:
pio-environment-list: '["ble_example", "basicUsage"]'

PlatformIO-Package:
if: ${{ (github.ref_type != 'tag') && (github.ref_name == 'master') }}
needs: PlatformIO-Build
uses: ./.github/workflows/platformio_publish_template.yml
with:
should-publish: false

PlatformIO-Publish:
uses: ./.github/workflows/platformio_publish_template.yml
if: ${{ (github.ref_type == 'tag') && (github.ref_name == 'master') }}
needs: PlatformIO-Build
with:
should-publish: true
secrets:
pio-registry-token: ${{ secrets.PIO_MKTSW_TOKEN }}

0 comments on commit 542ff19

Please sign in to comment.