Sync and release #39
This file contains hidden or 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
| # Sync generated/lvgl_python.c, lv_conf.h, and lvgl from PyDevices/lvgl-bindings on GitHub, | |
| # commit the next version to main and publish its GitHub Release. | |
| # | |
| # Run from the GitHub Actions tab (workflow_dispatch) or without cloning this repo: | |
| # gh workflow run sync-and-release.yml --repo PyDevices/lvgl-python | |
| # gh workflow run sync-and-release.yml --repo PyDevices/lvgl-python -f lvgl_bindings_ref=abc1234 | |
| # | |
| # Prerequisite: commit regenerated generated/lvgl_python.c (and lv_conf.h if changed) to | |
| # lvgl-bindings first — sync reads from GitHub, not your local machine. | |
| name: Sync and release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| lvgl_bindings_ref: | |
| description: lvgl-bindings branch, tag, or commit SHA | |
| type: string | |
| default: main | |
| skip_publish: | |
| description: Sync and commit only; do not create a release tag | |
| type: boolean | |
| default: false | |
| permissions: | |
| contents: write | |
| jobs: | |
| sync-and-release: | |
| runs-on: ubuntu-latest | |
| if: github.repository == 'PyDevices/lvgl-python' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| submodules: recursive | |
| - name: Resolve lvgl-bindings ref | |
| id: lvgl_bindings_ref | |
| run: | | |
| REF="${{ inputs.lvgl_bindings_ref }}" | |
| if [[ -z "$REF" ]]; then | |
| REF="main" | |
| fi | |
| echo "ref=${REF}" >> "$GITHUB_OUTPUT" | |
| echo "Syncing from lvgl-bindings @ ${REF}" | |
| - name: Sync from lvgl-bindings | |
| run: ./scripts/sync_from_lvgl_bindings.sh --ref "${{ steps.lvgl_bindings_ref.outputs.ref }}" | |
| - name: Commit versioned sync | |
| id: commit | |
| env: | |
| LV_BINDINGS_REF: ${{ steps.lvgl_bindings_ref.outputs.ref }} | |
| run: | | |
| set -euo pipefail | |
| git config user.name 'github-actions[bot]' | |
| git config user.email 'github-actions[bot]@users.noreply.github.com' | |
| if git diff --quiet && git diff --cached --quiet; then | |
| echo "changed=false" >> "$GITHUB_OUTPUT" | |
| echo "Already in sync with lvgl-bindings ${LV_BINDINGS_REF}." | |
| else | |
| git fetch --tags origin | |
| VERSION="$(./scripts/next_release_version.sh)" | |
| printf '%s\n' "$VERSION" > VERSION | |
| git add VERSION generated/lvgl_python.c generated/lvgl.pyi lv_conf.h display_driver.py lvgl | |
| git commit -m "Sync bindings and LVGL from lvgl-bindings ${LV_BINDINGS_REF}." | |
| git push origin HEAD:main | |
| echo "changed=true" >> "$GITHUB_OUTPUT" | |
| echo "version=${VERSION}" >> "$GITHUB_OUTPUT" | |
| echo "Committed and pushed sync from lvgl-bindings ${LV_BINDINGS_REF}." | |
| fi | |
| - name: Publish GitHub Release | |
| if: inputs.skip_publish != true && steps.commit.outputs.changed == 'true' | |
| env: | |
| GH_TOKEN: ${{ secrets.RELEASE_WORKFLOW_TOKEN }} | |
| VERSION: ${{ steps.commit.outputs.version }} | |
| run: | | |
| set -euo pipefail | |
| if [[ -z "${GH_TOKEN:-}" ]]; then | |
| echo "Error: RELEASE_WORKFLOW_TOKEN is required to publish the release." >&2 | |
| exit 1 | |
| fi | |
| gh release create "v${VERSION}" \ | |
| --repo "${{ github.repository }}" \ | |
| --target "$(git rev-parse HEAD)" \ | |
| --title "v${VERSION}" \ | |
| --generate-notes | |
| echo "Published GitHub Release v${VERSION}" | |
| - name: No release tag | |
| if: inputs.skip_publish != true && steps.commit.outputs.changed != 'true' | |
| run: echo "No changes after sync — GitHub Release skipped." | |
| - name: Skipped publish | |
| if: inputs.skip_publish == true | |
| run: echo "skip_publish=true — no GitHub Release was published." |