Skip to content

Commit 65608e6

Browse files
authored
Merge pull request #54 from rota1001/ci-update
Detect workflow file changes to trigger LKL build
2 parents 00007b6 + 000074b commit 65608e6

1 file changed

Lines changed: 26 additions & 8 deletions

File tree

.github/workflows/build-lkl.yml

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,12 @@ jobs:
3636
contents: read
3737
outputs:
3838
lkl_commit: ${{ steps.head.outputs.commit }}
39+
yml_hash: ${{ steps.compare.outputs.yml_hash }}
3940
needs_build: ${{ steps.compare.outputs.needs_build }}
4041
steps:
42+
- name: Checkout repository
43+
uses: actions/checkout@v6
44+
4145
- name: Get upstream LKL HEAD
4246
id: head
4347
run: |
@@ -54,25 +58,37 @@ jobs:
5458
env:
5559
GH_TOKEN: ${{ github.token }}
5660
run: |
61+
CURRENT_YML=$(sha256sum .github/workflows/build-lkl.yml | awk '{print $1}')
62+
echo "yml_hash=${CURRENT_YML}" >> "$GITHUB_OUTPUT"
63+
5764
if [ "${{ inputs.force }}" = "true" ]; then
5865
echo "needs_build=true" >> "$GITHUB_OUTPUT"
5966
echo "Forced rebuild requested."
6067
exit 0
6168
fi
6269
6370
# Fetch BUILD_INFO from existing nightly release.
64-
LAST_COMMIT=$(gh release view "${{ env.NIGHTLY_TAG }}" \
71+
LAST_RELEASE=$(gh release view "${{ env.NIGHTLY_TAG }}" \
6572
--repo "${{ env.KBOX_REPO }}" \
66-
--json body --jq '.body' 2>/dev/null \
73+
--json body --jq '.body' 2>/dev/null) || LAST_RELEASE=""
74+
75+
LAST_COMMIT=$(echo "$LAST_RELEASE" \
6776
| grep -oP 'commit=\K[0-9a-f]+' | head -1) || LAST_COMMIT=""
6877
69-
CURRENT="${{ steps.head.outputs.commit }}"
70-
if [ "$LAST_COMMIT" = "$CURRENT" ]; then
71-
echo "needs_build=false" >> "$GITHUB_OUTPUT"
72-
echo "Upstream unchanged (${CURRENT}). Skipping build."
73-
else
78+
LAST_YML=$(echo "$LAST_RELEASE" \
79+
| grep -oP 'yml_hash=\K[0-9a-f]+' | head -1) || LAST_YML=""
80+
81+
CURRENT_COMMIT="${{ steps.head.outputs.commit }}"
82+
83+
if [ "$LAST_COMMIT" != "$CURRENT_COMMIT" ]; then
84+
echo "needs_build=true" >> "$GITHUB_OUTPUT"
85+
echo "New upstream commit: ${CURRENT_COMMIT} (was: ${LAST_COMMIT:-none})"
86+
elif [ "$LAST_YML" != "$CURRENT_YML" ]; then
7487
echo "needs_build=true" >> "$GITHUB_OUTPUT"
75-
echo "New upstream commit: ${CURRENT} (was: ${LAST_COMMIT:-none})"
88+
echo "build-lkl.yml was changed"
89+
else
90+
echo "needs_build=false" >> "$GITHUB_OUTPUT"
91+
echo "Upstream unchanged (${CURRENT_COMMIT}) and the build script unchanged. Skipping build."
7692
fi
7793
7894
# ---- Build x86_64, aarch64 and riscv64 in parallel ----
@@ -144,12 +160,14 @@ jobs:
144160
GH_TOKEN: ${{ github.token }}
145161
run: |
146162
LKL_COMMIT="${{ needs.check-upstream.outputs.lkl_commit }}"
163+
YML_HASH="${{ needs.check-upstream.outputs.yml_hash }}"
147164
BUILD_DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ)
148165
149166
cat > /tmp/release-notes.md <<EOF
150167
Nightly prebuilt liblkl.a for kbox.
151168
152169
commit=${LKL_COMMIT}
170+
yml_hash=${YML_HASH}
153171
date=${BUILD_DATE}
154172
upstream=https://github.com/${{ env.LKL_UPSTREAM }}/commit/${LKL_COMMIT}
155173

0 commit comments

Comments
 (0)