-
Notifications
You must be signed in to change notification settings - Fork 0
117 lines (104 loc) · 3.83 KB
/
Copy pathsync-and-release.yml
File metadata and controls
117 lines (104 loc) · 3.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
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