diff --git a/.github/workflows/platformio_build_template.yml b/.github/workflows/platformio_build_template.yml index d6bdb49..c7b75dc 100644 --- a/.github/workflows/platformio_build_template.yml +++ b/.github/workflows/platformio_build_template.yml @@ -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 }} diff --git a/.github/workflows/platformio_check_template.yml b/.github/workflows/platformio_check_template.yml index 34bed65..be39b44 100644 --- a/.github/workflows/platformio_check_template.yml +++ b/.github/workflows/platformio_check_template.yml @@ -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 }} diff --git a/.github/workflows/platformio_publish_template.yml b/.github/workflows/platformio_publish_template.yml index cc6b11a..b1ed074 100644 --- a/.github/workflows/platformio_publish_template.yml +++ b/.github/workflows/platformio_publish_template.yml @@ -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 @@ -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 }} diff --git a/.github/workflows/platformio_workflow.yml b/.github/workflows/platformio_workflow.yml index 508e453..148ae61 100644 --- a/.github/workflows/platformio_workflow.yml +++ b/.github/workflows/platformio_workflow.yml @@ -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 }}