Skip to content

Added

Added #16

Workflow file for this run

name: Test and Release
on:
push:
branches:
- main
jobs:
update-version:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Set Up Git
run: |
git config --global user.name "${{ vars.USER_NAME }}"
git config --global user.email "${{ vars.USER_EMAIL }}"
- name: Get Latest Release Version
id: get_version
run: |
latest_version=$(curl -s https://api.github.com/repos/mauro-midolo/ESP32-heltec-oled-logger/releases/latest | jq -r .tag_name)
echo "Latest Version: $latest_version"
next_version=$(python -c "parts = '$latest_version'.split('.'); parts[-1] = str(int(parts[-1]) + 1); print('.'.join(parts))")
next_version_no_v=$(python -c "parts = '$latest_version'.split('.'); parts[-1] = str(int(parts[-1]) + 1); print('.'.join(parts).replace('v',''))")
echo "Next Version: $next_version"
echo "Next Version no version: $next_version_no_v"
echo "::set-output name=version::$next_version"
echo "::set-output name=version_noversion::$next_version_no_v"
- name: Update Version in File
run: |
sed -i 's/\(mauro-midolo\/ESP32 Heltec OLED Logger@^\)[0-9.]\+/\1'"${{ steps.get_version.outputs.version_noversion }}"'/' ./examples/example1/platformio.ini
python -c "import json; data = json.load(open('library.json')); data['version'] = '${{ steps.get_version.outputs.version_noversion }}'; json.dump(data, open('library.json', 'w'))"
- name: Commit Changes
run: |
git add ./examples/example1/platformio.ini library.json
git commit -m "Upgrade version from $latest_version to $next_version"
git push origin main
- name: Create GitHub Release
uses: actions/create-release@v1
with:
tag_name: ${{ steps.get_version.outputs.version }}
release_name: ${{ steps.get_version.outputs.version }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v1
- name: Install PlatformIO
run: |
python -m pip install --upgrade pip
pip install platformio
- name: Release into PlatformIO
run: |
pio pkg publish --no-interactive
env:
PLATFORMIO_AUTH_TOKEN: ${{ secrets.PLATFORMIO_AUTH_TOKEN }}