Skip to content

Commit ad54753

Browse files
16bit-ykikoclaude
andcommitted
feat: automate LLVM build-upload-PR pipeline
- Add llvm_version and skip_upload inputs to build-llvm workflow - Add upload job to auto-publish artifacts to clice-llvm repo - Add update-clice job to auto-create PR with version bump - Extract distribution components list to scripts/llvm-components.json - Add validate-llvm-components.py to catch stale/renamed components - Add update-llvm-version.py to update manifest and package.cmake Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent 7a2f93e commit ad54753

File tree

5 files changed

+485
-99
lines changed

5 files changed

+485
-99
lines changed

.github/workflows/build-llvm.yml

Lines changed: 116 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@ name: build llvm
22

33
on:
44
workflow_dispatch:
5+
inputs:
6+
llvm_version:
7+
description: "LLVM version to build (e.g., 21.1.8)"
8+
required: true
9+
type: string
10+
skip_upload:
11+
description: "Skip upload and PR creation (build-only mode)"
12+
required: false
13+
type: boolean
14+
default: false
515
pull_request:
616
# if you want to run this workflow, change the branch name to main,
717
# if you want to turn off it, change it to non existent branch.
@@ -107,10 +117,19 @@ jobs:
107117
cache: true
108118
locked: true
109119

110-
- name: Clone llvm-project (21.1.8)
120+
- name: Clone llvm-project
111121
shell: bash
112122
run: |
113-
git clone --branch llvmorg-21.1.8 --depth 1 https://github.com/llvm/llvm-project.git .llvm
123+
VERSION="${{ inputs.llvm_version || '21.1.8' }}"
124+
echo "Cloning LLVM ${VERSION}..."
125+
git clone --branch "llvmorg-${VERSION}" --depth 1 https://github.com/llvm/llvm-project.git .llvm
126+
127+
- name: Validate distribution components
128+
shell: bash
129+
run: |
130+
python3 scripts/validate-llvm-components.py \
131+
--llvm-src=.llvm \
132+
--components-file=scripts/llvm-components.json
114133
115134
- name: Build LLVM (install-distribution)
116135
shell: bash
@@ -265,3 +284,98 @@ jobs:
265284
name: ${{ env.LLVM_INSTALL_ARCHIVE }}
266285
path: ${{ env.LLVM_INSTALL_ARCHIVE }}
267286
if-no-files-found: error
287+
288+
# ── Upload to clice-llvm ────────────────────────────────────────────────
289+
upload:
290+
needs: build
291+
if: ${{ inputs.llvm_version && !inputs.skip_upload }}
292+
runs-on: ubuntu-24.04
293+
permissions:
294+
contents: read
295+
steps:
296+
- uses: actions/checkout@v4
297+
298+
- name: Download all build artifacts
299+
env:
300+
GH_TOKEN: ${{ github.token }}
301+
run: scripts/download-llvm.sh "${{ github.run_id }}"
302+
303+
- name: Upload to clice-llvm
304+
env:
305+
GH_TOKEN: ${{ secrets.UPLOAD_LLVM }}
306+
TARGET_REPO: clice-io/clice-llvm
307+
run: python3 scripts/upload-llvm.py "${{ inputs.llvm_version }}" "${TARGET_REPO}" "${{ github.run_id }}"
308+
309+
- name: Save manifest for update-clice job
310+
uses: actions/upload-artifact@v4
311+
with:
312+
name: llvm-manifest-final
313+
path: artifacts/llvm-manifest.json
314+
if-no-files-found: error
315+
compression-level: 0
316+
317+
# ── Auto-create PR to update clice LLVM dependency ──────────────────────
318+
update-clice:
319+
needs: upload
320+
runs-on: ubuntu-24.04
321+
permissions:
322+
contents: write
323+
pull-requests: write
324+
steps:
325+
- uses: actions/checkout@v4
326+
327+
- name: Download manifest
328+
uses: actions/download-artifact@v4
329+
with:
330+
name: llvm-manifest-final
331+
path: .
332+
333+
- name: Update manifest and version
334+
run: |
335+
python3 scripts/update-llvm-version.py \
336+
--version "${{ inputs.llvm_version }}" \
337+
--manifest-src llvm-manifest.json \
338+
--manifest-dest config/llvm-manifest.json \
339+
--package-cmake cmake/package.cmake
340+
341+
- name: Create or update PR
342+
env:
343+
GH_TOKEN: ${{ github.token }}
344+
run: |
345+
VERSION="${{ inputs.llvm_version }}"
346+
BRANCH="chore/update-llvm-${VERSION}"
347+
RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
348+
RELEASE_URL="https://github.com/clice-io/clice-llvm/releases/tag/${VERSION}"
349+
350+
git config user.name "github-actions[bot]"
351+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
352+
git checkout -b "${BRANCH}"
353+
git add config/llvm-manifest.json cmake/package.cmake
354+
git commit -m "chore: update LLVM to ${VERSION}"
355+
git push --force-with-lease origin "${BRANCH}"
356+
357+
# Check if PR already exists for this branch
358+
EXISTING_PR=$(gh pr list --head "${BRANCH}" --json number --jq '.[0].number // empty')
359+
360+
BODY="$(cat <<EOF
361+
## Summary
362+
- Update LLVM prebuilt binaries to version ${VERSION}
363+
- Updated \`config/llvm-manifest.json\` with new SHA256 hashes
364+
- Updated \`cmake/package.cmake\` version string
365+
366+
**Artifacts:** [clice-llvm release](${RELEASE_URL})
367+
**Build:** [workflow run](${RUN_URL})
368+
369+
> Auto-generated by build-llvm workflow
370+
EOF
371+
)"
372+
373+
if [[ -n "${EXISTING_PR}" ]]; then
374+
echo "Updating existing PR #${EXISTING_PR}"
375+
gh pr edit "${EXISTING_PR}" --body "${BODY}"
376+
else
377+
gh pr create \
378+
--title "chore: update LLVM to ${VERSION}" \
379+
--body "${BODY}" \
380+
--base main
381+
fi

scripts/build-llvm.py

Lines changed: 4 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import shutil
55
import argparse
66
import os
7+
import json
78
from pathlib import Path
89

910

@@ -96,103 +97,9 @@ def main():
9697
print(f"Toolchain: {toolchain_file}")
9798
print("---------------------")
9899

99-
llvm_distribution_components = [
100-
"LLVMDemangle",
101-
"LLVMSupport",
102-
"LLVMCore",
103-
"LLVMOption",
104-
"LLVMBinaryFormat",
105-
"LLVMMC",
106-
"LLVMMCParser",
107-
"LLVMObject",
108-
"LLVMProfileData",
109-
"LLVMBitReader",
110-
"LLVMBitstreamReader",
111-
"LLVMRemarks",
112-
"LLVMObjectYAML",
113-
"LLVMAggressiveInstCombine",
114-
"LLVMInstCombine",
115-
"LLVMIRReader",
116-
"LLVMTextAPI",
117-
"LLVMSymbolize",
118-
"LLVMDebugInfoDWARF",
119-
"LLVMDebugInfoDWARFLowLevel",
120-
"LLVMDebugInfoCodeView",
121-
"LLVMDebugInfoGSYM",
122-
"LLVMDebugInfoPDB",
123-
"LLVMDebugInfoBTF",
124-
"LLVMDebugInfoMSF",
125-
"LLVMAsmParser",
126-
"LLVMTargetParser",
127-
"LLVMTransformUtils",
128-
"LLVMAnalysis",
129-
"LLVMScalarOpts",
130-
"LLVMFrontendHLSL",
131-
"LLVMFrontendOpenMP",
132-
"LLVMFrontendOffloading",
133-
"LLVMFrontendAtomic",
134-
"LLVMFrontendDirective",
135-
"LLVMWindowsDriver",
136-
"clangIndex",
137-
"clangAPINotes",
138-
"clangAST",
139-
"clangASTMatchers",
140-
"clangBasic",
141-
"clangDriver",
142-
"clangFormat",
143-
"clangFrontend",
144-
"clangLex",
145-
"clangParse",
146-
"clangSema",
147-
"clangSerialization",
148-
"clangRewrite",
149-
"clangAnalysis",
150-
"clangEdit",
151-
"clangSupport",
152-
"clangStaticAnalyzerCore",
153-
"clangStaticAnalyzerFrontend",
154-
"clangTidy",
155-
"clangTidyUtils",
156-
"clangTidyAndroidModule",
157-
"clangTidyAbseilModule",
158-
"clangTidyAlteraModule",
159-
"clangTidyBoostModule",
160-
"clangTidyBugproneModule",
161-
"clangTidyCERTModule",
162-
"clangTidyConcurrencyModule",
163-
"clangTidyCppCoreGuidelinesModule",
164-
"clangTidyDarwinModule",
165-
"clangTidyFuchsiaModule",
166-
"clangTidyGoogleModule",
167-
"clangTidyHICPPModule",
168-
"clangTidyLinuxKernelModule",
169-
"clangTidyLLVMModule",
170-
"clangTidyLLVMLibcModule",
171-
"clangTidyMiscModule",
172-
"clangTidyModernizeModule",
173-
"clangTidyObjCModule",
174-
"clangTidyOpenMPModule",
175-
"clangTidyPerformanceModule",
176-
"clangTidyPortabilityModule",
177-
"clangTidyReadabilityModule",
178-
"clangTidyZirconModule",
179-
"clangTooling",
180-
"clangToolingCore",
181-
"clangToolingInclusions",
182-
"clangToolingInclusionsStdlib",
183-
"clangToolingSyntax",
184-
"clangToolingRefactoring",
185-
"clangTransformer",
186-
"clangCrossTU",
187-
"clangAnalysisFlowSensitive",
188-
"clangAnalysisFlowSensitiveModels",
189-
"clangStaticAnalyzerCheckers",
190-
"clangIncludeCleaner",
191-
"llvm-headers",
192-
"clang-headers",
193-
"clang-tidy-headers",
194-
"clang-resource-headers",
195-
]
100+
components_path = Path(__file__).resolve().parent / "llvm-components.json"
101+
with components_path.open() as f:
102+
llvm_distribution_components = json.load(f)["components"]
196103

197104
components_joined = ";".join(llvm_distribution_components)
198105
cmake_args = [

scripts/llvm-components.json

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
{
2+
"components": [
3+
"LLVMDemangle",
4+
"LLVMSupport",
5+
"LLVMCore",
6+
"LLVMOption",
7+
"LLVMBinaryFormat",
8+
"LLVMMC",
9+
"LLVMMCParser",
10+
"LLVMObject",
11+
"LLVMProfileData",
12+
"LLVMBitReader",
13+
"LLVMBitstreamReader",
14+
"LLVMRemarks",
15+
"LLVMObjectYAML",
16+
"LLVMAggressiveInstCombine",
17+
"LLVMInstCombine",
18+
"LLVMIRReader",
19+
"LLVMTextAPI",
20+
"LLVMSymbolize",
21+
"LLVMDebugInfoDWARF",
22+
"LLVMDebugInfoDWARFLowLevel",
23+
"LLVMDebugInfoCodeView",
24+
"LLVMDebugInfoGSYM",
25+
"LLVMDebugInfoPDB",
26+
"LLVMDebugInfoBTF",
27+
"LLVMDebugInfoMSF",
28+
"LLVMAsmParser",
29+
"LLVMTargetParser",
30+
"LLVMTransformUtils",
31+
"LLVMAnalysis",
32+
"LLVMScalarOpts",
33+
"LLVMFrontendHLSL",
34+
"LLVMFrontendOpenMP",
35+
"LLVMFrontendOffloading",
36+
"LLVMFrontendAtomic",
37+
"LLVMFrontendDirective",
38+
"LLVMWindowsDriver",
39+
"clangIndex",
40+
"clangAPINotes",
41+
"clangAST",
42+
"clangASTMatchers",
43+
"clangBasic",
44+
"clangDriver",
45+
"clangFormat",
46+
"clangFrontend",
47+
"clangLex",
48+
"clangParse",
49+
"clangSema",
50+
"clangSerialization",
51+
"clangRewrite",
52+
"clangAnalysis",
53+
"clangEdit",
54+
"clangSupport",
55+
"clangStaticAnalyzerCore",
56+
"clangStaticAnalyzerFrontend",
57+
"clangTidy",
58+
"clangTidyUtils",
59+
"clangTidyAndroidModule",
60+
"clangTidyAbseilModule",
61+
"clangTidyAlteraModule",
62+
"clangTidyBoostModule",
63+
"clangTidyBugproneModule",
64+
"clangTidyCERTModule",
65+
"clangTidyConcurrencyModule",
66+
"clangTidyCppCoreGuidelinesModule",
67+
"clangTidyDarwinModule",
68+
"clangTidyFuchsiaModule",
69+
"clangTidyGoogleModule",
70+
"clangTidyHICPPModule",
71+
"clangTidyLinuxKernelModule",
72+
"clangTidyLLVMModule",
73+
"clangTidyLLVMLibcModule",
74+
"clangTidyMiscModule",
75+
"clangTidyModernizeModule",
76+
"clangTidyObjCModule",
77+
"clangTidyOpenMPModule",
78+
"clangTidyPerformanceModule",
79+
"clangTidyPortabilityModule",
80+
"clangTidyReadabilityModule",
81+
"clangTidyZirconModule",
82+
"clangTooling",
83+
"clangToolingCore",
84+
"clangToolingInclusions",
85+
"clangToolingInclusionsStdlib",
86+
"clangToolingSyntax",
87+
"clangToolingRefactoring",
88+
"clangTransformer",
89+
"clangCrossTU",
90+
"clangAnalysisFlowSensitive",
91+
"clangAnalysisFlowSensitiveModels",
92+
"clangStaticAnalyzerCheckers",
93+
"clangIncludeCleaner",
94+
"llvm-headers",
95+
"clang-headers",
96+
"clang-tidy-headers",
97+
"clang-resource-headers"
98+
]
99+
}

0 commit comments

Comments
 (0)