Skip to content

Sync and release

Sync and release #53

name: Sync and release
on:
workflow_dispatch:
inputs:
lvgl_bindings_ref:
description: Exact lvgl-bindings commit SHA or v9.5.N tag
required: true
type: string
mode:
description: Dry-run validates only; sync commits; release commits and publishes
required: true
default: dry-run
type: choice
options:
- dry-run
- sync
- release
permissions:
contents: write
jobs:
sync-and-release:
runs-on: ubuntu-latest
if: github.repository == 'PyDevices/lvgl-python'
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
submodules: recursive
- uses: actions/setup-python@v7
with:
python-version: "3.12"
- name: Validate exact bindings ref
env:
REF: ${{ inputs.lvgl_bindings_ref }}
run: |
if [[ ! "$REF" =~ ^[0-9a-fA-F]{40}$ && ! "$REF" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Expected an exact 40-character commit SHA or vX.Y.Z tag, got: $REF" >&2
exit 1
fi
- name: Sync exact bindings source
run: ./scripts/sync_from_lvgl_bindings.sh --ref "${{ inputs.lvgl_bindings_ref }}"
- name: Check out matching smoke suite
uses: actions/checkout@v7
with:
repository: PyDevices/lvgl-bindings
ref: ${{ inputs.lvgl_bindings_ref }}
path: lvgl-bindings
- name: Build and test extension
run: |
python -m pip install --upgrade pip
python -m pip install -e .
python -m unittest discover -s tests -v
python lvgl-bindings/tools/test_lvgl_smoke.py
- name: Compute expected version
id: version
run: |
git fetch --tags origin
VERSION=$(./scripts/next_release_version.sh)
[[ "$VERSION" == 9.5.* ]]
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "Expected version: $VERSION"
- name: Dry-run result
if: inputs.mode == 'dry-run'
run: echo "Validation passed; no commit, tag, push, release, or publication was made."
- name: Commit exact sync
id: commit
if: inputs.mode != 'dry-run'
env:
BINDINGS_REF: ${{ inputs.lvgl_bindings_ref }}
VERSION: ${{ steps.version.outputs.version }}
run: |
set -euo pipefail
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
printf '%s\n' "$VERSION" > VERSION
git add LVGL_BINDINGS_COMMIT VERSION generated/lvgl_python.c generated/lvgl.pyi lv_conf.h display_driver.py fs_driver.py lvgl
if git diff --cached --quiet; then
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "Already synchronized."
else
git commit -m "Sync bindings from ${BINDINGS_REF}."
git push origin HEAD:main
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Mint a repository-scoped installation token
id: app-token
if: inputs.mode == 'release' && steps.commit.outputs.changed == 'true'
uses: actions/create-github-app-token@v3
with:
app-id: ${{ secrets.PYDEVICES_APP_ID }}
private-key: ${{ secrets.PYDEVICES_APP_PRIVATE_KEY }}
owner: PyDevices
repositories: lvgl-python
- name: Publish GitHub release
if: inputs.mode == 'release' && steps.commit.outputs.changed == 'true'
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
VERSION: ${{ steps.version.outputs.version }}
run: |
gh release create "v${VERSION}" \
--repo "${{ github.repository }}" \
--target "$(git rev-parse HEAD)" \
--title "v${VERSION}" \
--generate-notes