Skip to content

Publish Library to PIO Registry #34

Publish Library to PIO Registry

Publish Library to PIO Registry #34

Workflow file for this run

name: Publish Library to PIO Registry
on:
workflow_dispatch:
inputs:
part_to_increment:
description: "Part to increment (1 for major, 2 for minor, 3 for patch)"
required: true
jobs:
publish:
name: Prepare Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install click
pip install --upgrade platformio
- name: Login to PlatformIO
run: |
pio account login -u "${{ secrets.PIO_USERNAME }}" -p "${{ secrets.PIO_PASSWORD }}"
- name: Update Version
env:
PART_TO_INCREMENT: ${{ github.event.inputs.part_to_increment }}
run: |
chmod +x version
./version "$PART_TO_INCREMENT"
echo "UPDATED_VERSION=$(grep "version=" library.properties | cut -d'=' -f2)" >> $GITHUB_ENV
- name: Commit changes
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
git add .
git commit -m "Update version to $UPDATED_VERSION"
git push origin master
- name: Create Tag
if: ${{ env.UPDATED_VERSION != '' }}
run: |
git tag -a "${{ env.UPDATED_VERSION }}" -m "Tagging version ${{ env.UPDATED_VERSION }}"
git push origin "${{ env.UPDATED_VERSION }}"
- name: Publish to PlatformIO
id: publish
run: yes y | pio pkg publish
continue-on-error: true
- name: Revert push and delete tag if publish fails
if: failure()
run: |
git reset --hard HEAD~1
git push origin +HEAD
git tag -d ${{ github.ref_name }}
git push origin :refs/tags/${{ github.ref_name }}
- name: Create GitHub Release
if: success()
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: LcdMenu v${{ github.ref_name }}
draft: true
prerelease: false