This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Aggiorna Versione, Commit e Rilascio | |
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: | | |
python -c "import json; data = json.load(open('library.json')); data['version'] = '$version_noversion'; json.dump(data, open('library.json', 'w'))" | |
- name: Update Version in platformio.ini | |
run: | | |
sed -i 's/\(mauro-midolo\/ESP32 Heltec OLED Logger@^\)[0-9.]\+/\1'"$version_noversion"'/' ./examples/example1/platformio.ini | |
- 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 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 }} | |