diff --git a/.github/workflows/prlint.yml b/.github/workflows/prlint.yml new file mode 100644 index 0000000..011afa1 --- /dev/null +++ b/.github/workflows/prlint.yml @@ -0,0 +1,11 @@ +name: Pull Request Message Validation +on: pull_request + +jobs: + prlint: + runs-on: ubuntu-latest + steps: + - name: Validate Pull Request + uses: amannn/action-semantic-pull-request@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 17470a6..53eccab 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,22 +1,66 @@ -name: PlatformIO Publish Release +name: Publish to PlatformIO + on: release: types: [released] jobs: - release: + pio-publish: runs-on: ubuntu-latest - env: - PLATFORMIO_AUTH_TOKEN: ${{ secrets.PLATFORMIO_AUTH_TOKEN }} + name: Publish a new Release to PlatformIO steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: '3.9' + python-version: "3.9" - name: Install PlatformIO Core run: | python -m pip install --upgrade pip pip install platformio - - name: Publish Release + - name: Install jq for handling JSON data + run: | + sudo apt update + sudo apt install -y jq + - name: Update Library Metadata and Configurations + run: | + LATEST_TAG=$(git describe --tags --abbrev=0) + LIB_V=$(jq -r .version library.json) + PROPS_V=$(cat library.properties | grep -oP version=\K.*) + if [ $LIB_V == $LATEST_TAG ]; then + sed -i -E "s/(version=).*/\1${LATEST_TAG}/" library.properties + echo ✅ Successfully Modified release tag in library.json file... + elif [ $PROPS_V == $LATEST_TAG ]; then + jq ".version = \"${LATEST_TAG}\"" library.json > temp.json && mv temp.json library.json + echo ✅ Successfully Modified release tag in library.properties file... + fi + - name: Publish to PlatformIO + env: + PLATFORMIO_AUTH_TOKEN: ${{ secrets.PLATFORMIO_AUTH_TOKEN }} run: | pio package publish --no-interactive --type library + echo 👍 Successfully published to PlatformIO + + update-lib-versions: + runs-on: ubuntu-latest + name: Update versions in library.json and library.properties + needs: pio-publish + steps: + - uses: actions/checkout@v4 + with: + fetch-tags: true + - name: Update library versions + run: | + LATEST_TAG=$(git describe --tags --abbrev=0) + sed -i -E "s/(version=).*/\1${LATEST_TAG}/" library.properties + jq ".version = \"${LATEST_TAG}\"" library.json > temp.json && mv temp.json library.json + - name: Push to main branch using PAT + env: + # new fine-grained PAT with contents = rw + PAT: ${{ secrets.CI_PAT }} + run: | + git config --global user.name "GitHub Actions" + git config --global user.email "actions@github.com" + git remote set-url origin https://x-access-token:${{ env.PAT }}@github.com/${{ github.repository }} + git add library.json library.properties + git commit -m "Automated update: Update library.json library.properties" + git push diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..4f5dfb5 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,35 @@ +name: Version Release + +on: + workflow_run: + workflows: ["PlatformIO Unit Tests"] + types: + - completed + +jobs: + gh-release: + name: Release a new Version + runs-on: ubuntu-latest + permissions: + contents: write + issues: write + pull-requests: write + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: latest + - name: GitHub Release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + npm init -y + npm install --save-dev \ + semantic-release \ + @semantic-release/commit-analyzer \ + @semantic-release/release-notes-generator \ + @semantic-release/git \ + @semantic-release/changelog \ + @semantic-release/github + npx semantic-release@24.2.1 + echo 👍 Successfully released a new version diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 661b010..219369d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -19,7 +19,7 @@ jobs: key: ${{ runner.os }}-pio - uses: actions/setup-python@v4 with: - python-version: '3.9' + python-version: "3.9" - name: Install PlatformIO Core run: | python -m pip install --upgrade pip @@ -30,4 +30,3 @@ jobs: run: platformio run -e arduino_uno -t build_test.cpp - name: Run Build Test for ESP32 Dev Module run: platformio run -e esp32dev -t build_test.cpp - diff --git a/.releaserc b/.releaserc new file mode 100644 index 0000000..43a710c --- /dev/null +++ b/.releaserc @@ -0,0 +1,12 @@ +{ + "branches": [ + "main" + ], + "plugins": [ + "@semantic-release/commit-analyzer", + "@semantic-release/release-notes-generator", + "@semantic-release/git", + "@semantic-release/changelog", + "@semantic-release/github" + ] +} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0230747..3cd59c0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,7 +12,9 @@ Open an issue on the repository and provide the following information: ## Code Convention -- Don't include C++ standard library functions, because it does not compile for AVR boards (C std libs still works). +- Don't include C++ standard library functions, because it does not compile for AVR boards (C std libs still works). + +- **Note:** All commits and pull requests must follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/). Please ensure your messages are properly formatted. ## Testing