-
Notifications
You must be signed in to change notification settings - Fork 0
109 lines (97 loc) · 4.14 KB
/
Copy pathsync-and-release.yml
File metadata and controls
109 lines (97 loc) · 4.14 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
# 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
# Not GITHUB_TOKEN: a Release created with it does not trigger
# `on: release` workflows, so publish-release-packages.yml would never
# run and nothing would reach TestPyPI. An App installation token does
# trigger them.
- name: Mint an installation token for this repository
id: app-token
if: inputs.skip_publish != true && steps.commit.outputs.changed == 'true'
uses: actions/create-github-app-token@v2
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.skip_publish != true && steps.commit.outputs.changed == 'true'
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
VERSION: ${{ steps.commit.outputs.version }}
run: |
set -euo pipefail
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."